Created
May 17, 2022 09:26
-
-
Save Soul-Master/ad4513e8a8338beca1fd3ebe10ceecc3 to your computer and use it in GitHub Desktop.
Detect ES version of file
This file contains 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 detect = require('detect-es-version'); | |
const path = require('path'); | |
async function main() { | |
const file = path.resolve('./file-to-be-detect.js'); | |
const ecmaVersion = await detect.getEntryPointEcmaVersion(file); | |
console.log(file, ecmaVersion); // prints 2015 | |
} | |
main() | |
.catch(reason => { | |
error(reason); | |
process.exit(1); | |
}); |
This file contains 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": "es-version", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"detect-es-version": "^0.1.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment