New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

amd-driver-scripts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amd-driver-scripts - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

.npmignore

18

index.js

@@ -78,14 +78,18 @@ var fs = require('fs'),

module.exports.isDriverScript = function (filename) {
var src = fs.readFileSync(filename).toString(),
var src = fs.readFileSync(filename, 'utf8'),
walker = new Walker(),
foundTopLevelModule = false;
walker.walk(src, function (node) {
if (types.isTopLevelRequire(node)) {
foundTopLevelModule = true;
walker.stopWalking();
}
});
try {
walker.walk(src, function (node) {
if (types.isTopLevelRequire(node)) {
foundTopLevelModule = true;
walker.stopWalking();
}
});
} catch(SyntaxError) {
return false;
}
return foundTopLevelModule;
};
{
"name": "amd-driver-scripts",
"version": "0.1.0",
"version": "1.0.0",
"description": "Get a list of entry-point, app initialization AMD modules (i.e., driver scripts) within a directory ",

@@ -5,0 +5,0 @@ "bin": {

var getDriverScripts = require('../'),
isDriverScript = require('../').isDriverScript;
isDriverScript = require('../').isDriverScript,
testCount = 0,
passCount = 0;
getDriverScripts(__dirname + '/example', function(drivers) {
console.log('Driver scripts found: ', drivers);
function equiv(expected, actual) {
if (Array.isArray(expected)) {
return expected.every(function(value, index) {
return value === actual[index];
});
} else {
return expected === actual;
}
}
console.log(drivers.length === 1);
console.log(drivers[0].indexOf('a.js') !== -1);
function assert(name, expected, actual) {
// weak equivalence for array comparison
var success = equiv(expected, actual),
label = success ? 'PASS' : 'FAIL';
testCount++;
if (success) {
passCount++;
} else {
console.error('expected', actual, 'to match', expected);
}
console.log(label, name);
}
function assertFile(filename, expected) {
assert('Is ' + filename + ' a driver script?', expected, isDriverScript(__dirname + '/fixtures/' + filename));
}
function logResults() {
console.log('-----------');
if (passCount === testCount) {
console.log('ALL TESTS PASSED');
} else {
console.error(passCount + '/' + testCount + ' tests passed');
}
console.log('-----------');
}
assertFile('driver.js', true);
assertFile('define.js', false);
assertFile('unparseable.js', false);
getDriverScripts(__dirname + '/fixtures', function(drivers) {
var driverFileNames = drivers.map(function(filename) {
return filename.split('/').reverse()[0];
});
assert('Found correct number of driver scripts', 1, drivers.length);
assert('Found correct list of files', ['driver.js'], driverFileNames);
logResults();
});
var result = isDriverScript(__dirname + '/example/a.js');
console.log('Is a.js a driver script?', result === true);
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