module-definition
Advanced tools
Comparing version 2.2.3 to 2.2.4
37
index.js
@@ -17,2 +17,3 @@ var Walker = require('node-source-walk'); | ||
var walker = new Walker(); | ||
var type = 'none'; | ||
var hasDefine = false; | ||
@@ -24,5 +25,2 @@ var hasAMDTopLevelRequire = false; | ||
var hasES6Export = false; | ||
var isAMD; | ||
var isCommonJS; | ||
var isES6; | ||
@@ -54,22 +52,23 @@ // Walker accepts as AST to avoid reparsing | ||
} | ||
}); | ||
isAMD = hasDefine || hasAMDTopLevelRequire; | ||
isCommonJS = hasExports || (hasRequire && !hasDefine); | ||
isES6 = hasES6Import || hasES6Export; | ||
if (hasES6Import || hasES6Export) { | ||
type = 'es6'; | ||
walker.stopWalking(); | ||
return; | ||
} | ||
// ES6 features are so unique that we can eagerly exit. (#19) | ||
if (isES6) { | ||
return 'es6'; | ||
} | ||
if (hasDefine || hasAMDTopLevelRequire) { | ||
type = 'amd'; | ||
walker.stopWalking(); | ||
return; | ||
} | ||
if (isAMD) { | ||
return 'amd'; | ||
} | ||
if (hasExports || (hasRequire && !hasDefine)) { | ||
type = 'commonjs'; | ||
walker.stopWalking(); | ||
return; | ||
} | ||
}); | ||
if (isCommonJS) { | ||
return 'commonjs'; | ||
} | ||
return 'none'; | ||
return type; | ||
} | ||
@@ -76,0 +75,0 @@ |
{ | ||
"name": "module-definition", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "Determines if a file is using a CommonJS or AMD module definition", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4571