module-definition
Determines the module definition type (CommonJS, AMD, or none) for a given JavaScript file
by walking through the AST.
npm install module-definition
Usage
var getModuleType = require('module-definition');
getModuleType('myscript.js', function (type) {
console.log(type);
});
var type = getModuleType.sync('myscript.js');
console.log(type);
var type = getModuleType.fromSource('define({foo: "foo"});');
console.log(type);
Or via shell command (requires a global install: npm install -g module-definition
)
module-definition filename
Passes one of the following strings to the given callback or returns the string in sync api: