Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

module-definition

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-definition - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

4

bin/module-definition.js

@@ -5,5 +5,5 @@ #!/usr/bin/env node

var getModuleType = require('../'),
filename = process.argv[2];
var getModuleType = require('../');
var filename = process.argv[2];
console.log(getModuleType.sync(filename));

@@ -1,4 +0,4 @@

var Walker = require('node-source-walk'),
types = require('ast-module-types'),
fs = require('fs');
var Walker = require('node-source-walk');
var types = require('ast-module-types');
var fs = require('fs');

@@ -12,14 +12,16 @@ /**

function fromSource(source) {
if (typeof source === 'undefined') throw new Error('source not supplied');
if (typeof source === 'undefined') {
throw new Error('source not supplied');
}
var walker = new Walker({
ecmaVersion: 6
}),
hasDefine = false,
hasAMDTopLevelRequire = false,
hasRequire = false,
hasExports = false,
hasES6Import = false,
hasES6Export = false,
isAMD, isCommonJS, isES6;
var walker = new Walker();
var hasDefine = false;
var hasAMDTopLevelRequire = false;
var hasRequire = false;
var hasExports = false;
var hasES6Import = false;
var hasES6Export = false;
var isAMD;
var isCommonJS;
var isES6;

@@ -57,4 +59,3 @@ // Walker accepts as AST to avoid reparsing

// ES6 features are so unique that we can
// eagerly exit. (#19)
// ES6 features are so unique that we can eagerly exit. (#19)
if (isES6) {

@@ -82,5 +83,7 @@ return 'es6';

function sync(file) {
if (!file) throw new Error('filename missing');
if (!file) {
throw new Error('filename missing');
}
var data = fs.readFileSync(file);
var data = fs.readFileSync(file, 'utf8');
return fromSource(data.toString());

@@ -104,3 +107,5 @@ }

fs.readFile(filepath, { encoding: 'utf8' }, function(err, data) {
var opts = {encoding: 'utf8'};
fs.readFile(filepath, opts, function(err, data) {
if (err) {

@@ -107,0 +112,0 @@ return cb(err);

{
"name": "module-definition",
"version": "2.2.1",
"version": "2.2.2",
"description": "Determines if a file is using a CommonJS or AMD module definition",

@@ -10,3 +10,3 @@ "main": "index.js",

"scripts": {
"test": "jscs test/test.js index.js bin/module-definition.js -p airbnb && mocha test/test.js"
"test": "jscs test/test.js index.js bin/module-definition.js -p google && mocha test/test.js"
},

@@ -21,9 +21,9 @@ "repository": {

"dependencies": {
"ast-module-types": "~2.2.2",
"node-source-walk": "~1.4.0"
"ast-module-types": "^2.3.0",
"node-source-walk": "^2.0.0"
},
"devDependencies": {
"jscs": "~1.7.3",
"jscs": "~1.13.1",
"mocha": "~2.0.1"
}
}

@@ -1,6 +0,6 @@

var getModuleType = require('../'),
path = require('path'),
fs = require('fs'),
assert = require('assert'),
amdAST = require('./amdAST');
var getModuleType = require('../');
var path = require('path');
var fs = require('fs');
var assert = require('assert');
var amdAST = require('./amdAST');

@@ -48,4 +48,5 @@ describe('module-definition', function() {

it('should return `' + result + '` as type of ' + filename, function() {
var source = fs.readFileSync(path.resolve(__dirname, filename), 'utf8'),
type = getModuleType.fromSource(source);
var source = fs.readFileSync(path.resolve(__dirname, filename), 'utf8');
var type = getModuleType.fromSource(source);
assert.equal(type, result);

@@ -52,0 +53,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc