strider-extension-loader
Advanced tools
Comparing version 0.0.2 to 0.0.4
22
main.js
@@ -13,5 +13,4 @@ // | ||
// | ||
// Under a specified path **dir** [by default, process.cwd()/node_modules] look | ||
// for directories containing file 'strider.json'. These are considered | ||
// Strider modules. | ||
// Under a specified path **dir** look for directories containing file | ||
// 'strider.json'. These are considered Strider modules. | ||
// | ||
@@ -23,5 +22,2 @@ // **cb** is a function of signature cb(err, extensions) where extensions is an | ||
// XXX May not be sane default when installed globally | ||
var dir = dir || path.join(process.cwd(), "node_modules"); | ||
var filename = "strider.json"; | ||
@@ -95,10 +91,14 @@ | ||
} | ||
// Build require'able path to extension sources | ||
var extension = { | ||
webapp: require(path.resolve(path.join(moduleDir, | ||
extensionConfig.webapp))), | ||
worker: require(path.resolve(path.join(moduleDir, | ||
extensionConfig.worker))), | ||
package: packageConfig | ||
}; | ||
if (extensionConfig.webapp) { | ||
var webapp = extensionConfig.webapp; | ||
extension.webapp = require(path.resolve(path.join(moduleDir, webapp))); | ||
} | ||
if (extensionConfig.worker) { | ||
var worker = extensionConfig.worker; | ||
extension.worker = require(path.resolve(path.join(moduleDir, worker))); | ||
} | ||
// Build require'able path to extension sources | ||
@@ -105,0 +105,0 @@ cb(null, extension); |
{ | ||
"name": "strider-extension-loader", | ||
"version": "0.0.2", | ||
"version": "0.0.4", | ||
"description": "Load Strider extensions", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -82,2 +82,4 @@ var exec = require('child_process').exec, | ||
mkpath("./node_modules_ext/foobar-strider"); | ||
mkpath("./node_modules_ext/foobar-strider-worker"); | ||
mkpath("./node_modules_ext/foobar-strider-webapp"); | ||
var strider_json = { | ||
@@ -91,3 +93,15 @@ webapp: "webapp.js", | ||
fs.writeFileSync("./node_modules_ext/foobar-strider/package.json", fs.readFileSync("package.json")); | ||
var strider_json = { | ||
webapp: "webapp.js", | ||
}; | ||
fs.writeFileSync("./node_modules_ext/foobar-strider-webapp/webapp.js", "exports.ok = function() { return true; };\n"); | ||
fs.writeFileSync("./node_modules_ext/foobar-strider-webapp/strider.json", JSON.stringify(strider_json)); | ||
fs.writeFileSync("./node_modules_ext/foobar-strider-webapp/package.json", fs.readFileSync("package.json")); | ||
var strider_json = { | ||
worker: "worker.js", | ||
}; | ||
fs.writeFileSync("./node_modules_ext/foobar-strider-worker/worker.js", "exports.ok = function() { return true; };\n"); | ||
fs.writeFileSync("./node_modules_ext/foobar-strider-worker/strider.json", JSON.stringify(strider_json)); | ||
fs.writeFileSync("./node_modules_ext/foobar-strider-worker/package.json", fs.readFileSync("package.json")); | ||
@@ -125,2 +139,26 @@ }); | ||
it("should load worker-only extensions", function(done) { | ||
loader.loadExtension("./node_modules_ext/foobar-strider-worker/", function(err, extension) { | ||
expect(err).not.to.exist; | ||
expect(extension).to.exist; | ||
expect(extension.webapp).not.to.exist; | ||
expect(extension.worker.ok()).to.be.true; | ||
expect(extension.package.name).to.eql("strider-extension-loader"); | ||
done(); | ||
}); | ||
}); | ||
it("should load webapp-only extensions", function(done) { | ||
loader.loadExtension("./node_modules_ext/foobar-strider-webapp/", function(err, extension) { | ||
expect(err).not.to.exist; | ||
expect(extension).to.exist; | ||
expect(extension.worker).not.to.exist; | ||
expect(extension.webapp.ok()).to.be.true; | ||
expect(extension.package.name).to.eql("strider-extension-loader"); | ||
done(); | ||
}); | ||
}); | ||
after(function(done) { | ||
@@ -127,0 +165,0 @@ exec("rm -rf node_modules_ext", function() { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
14868
244
0
2