Skip to content

Instantly share code, notes, and snippets.

@Soul-Master
Created May 17, 2022 09:26
Show Gist options
  • Save Soul-Master/ad4513e8a8338beca1fd3ebe10ceecc3 to your computer and use it in GitHub Desktop.
Save Soul-Master/ad4513e8a8338beca1fd3ebe10ceecc3 to your computer and use it in GitHub Desktop.
Detect ES version of file
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);
});
{
"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