Last active
December 30, 2019 15:28
-
-
Save tomhodgins/f915de310aac666815d07743a8976cc5 to your computer and use it in GitHub Desktop.
(be sure to run npm install to install those tasty dependencies!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const babel = require('@babel/core') | |
const fs = require('fs') | |
let file = process.argv.slice(2)[0] | |
let text = file | |
if (fs.existsSync(file)) { | |
text = fs.readFileSync(file).toString() | |
} | |
console.log( | |
babel.transform( | |
text, | |
{ | |
plugins: [ | |
require.resolve('@babel/plugin-transform-template-literals'), | |
] | |
} | |
).code | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "babel", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@babel/core": "^7.7.7", | |
"@babel/plugin-transform-template-literals": "^7.7.4" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`1 + 1 = ${1 + 1}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment