Socket
Socket
Sign inDemoInstall

commoner

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commoner - npm Package Compare versions

Comparing version 0.8.15 to 0.9.0

1

lib/cache.js

@@ -16,2 +16,3 @@ var assert = require("assert");

assert.ok(this instanceof ReadFileCache);
assert.strictEqual(typeof sourceDir, "string");

@@ -18,0 +19,0 @@ EventEmitter.call(this);

63

lib/commoner.js

@@ -71,4 +71,6 @@ var assert = require("assert");

Cp.buildP = function(config, options, sourceDir, outputDir, roots) {
Cp.buildP = function(options, roots) {
var self = this;
var sourceDir = options.sourceDir;
var outputDir = options.outputDir;
var readFileCache = new ReadFileCache(sourceDir);

@@ -112,3 +114,3 @@ var waiting = 0;

var context = new BuildContext(config, options, readFileCache);
var context = new BuildContext(options, readFileCache);

@@ -146,3 +148,6 @@ if (self.preferredFileExtension)

return lockOutputDirP(outputDir).then(rebuild);
return (
// If outputDir is falsy, we can't (and don't need to) mkdirP it.
outputDir ? Q.resolve : util.mkdirP
)(outputDir).then(rebuild);
};

@@ -183,18 +188,2 @@

function lockOutputDirP(outputDir) {
if (!outputDir) {
// If outputDir is falsy, then there's nothing to lock.
return Q.resolve(outputDir);
}
return util.mkdirP(outputDir).then(function(dir) {
var lockFile = path.join(outputDir, ".lock.pid");
return util.acquireLockFileP(lockFile).then(function() {
return dir;
}, function(err) {
throw new Error("output directory " + outputDir + " currently in use");
});
});
}
Cp.forceResolve = function(forceId, source) {

@@ -305,20 +294,23 @@ this.resolvers.unshift(function(id) {

var promise = Q.all([
getConfigP(
workingDir,
options.config
).then(function(config) {
if ("version" in config) {
// Leave it alone.
} else {
config.version = version;
var promise = getConfigP(
workingDir,
options.config
).then(function(config) {
var cleanOptions = {};
options.options.forEach(function(option) {
var name = util.camelize(option.name());
if (options.hasOwnProperty(name)) {
cleanOptions[name] = options[name];
}
return config;
}),
options,
sourceDir,
outputDir,
roots
]).spread(commoner.buildP.bind(commoner));
});
cleanOptions.version = version;
cleanOptions.config = config;
cleanOptions.sourceDir = sourceDir;
cleanOptions.outputDir = outputDir;
return commoner.buildP(cleanOptions, roots);
});
if (!commoner.watch) {

@@ -329,2 +321,3 @@ // If we're building from the command line without --watch, any

promise = promise.fail(function(err) {
log.err(err.stack);
process.exit(-1);

@@ -331,0 +324,0 @@ });

@@ -11,3 +11,3 @@ var assert = require("assert");

function BuildContext(config, options, readFileCache) {
function BuildContext(options, readFileCache) {
var self = this;

@@ -17,10 +17,15 @@ assert.ok(self instanceof BuildContext);

config = config || {};
Object.freeze(config);
if (options) {
assert.strictEqual(typeof options, "object");
} else {
options = {};
}
Object.freeze(options);
Object.defineProperties(self, {
readFileCache: { value: readFileCache },
config: { value: config },
config: { value: options.config },
options: { value: options },
configHash: { value: util.deepHash(config) }
optionsHash: { value: util.deepHash(options) }
});

@@ -27,0 +32,0 @@ }

@@ -18,3 +18,3 @@ var assert = require("assert");

var hash = createHash("sha1").update(context.configHash + "\0");
var hash = createHash("sha1").update(context.optionsHash + "\0");

@@ -21,0 +21,0 @@ function hashCallbacks(salt) {

@@ -82,30 +82,2 @@ var assert = require("assert");

exports.acquireLockFileP = function(file) {
return openExclusiveP(file).then(function(fd) {
function unlink(code) {
if (!unlink.ed) {
unlink.ed = true;
try {
fs.unlinkSync(file);
} catch (e) {
if (e.code === "ENOENT") {
// Don't worry if lock file was deleted.
} else {
log.err(e.stack);
}
}
process.exit(~~code);
}
}
process.on("exit", unlink);
process.on("SIGINT", unlink);
process.on("SIGTERM", unlink);
return writeFdP(fd, process.pid + "\n");
});
};
function readFromStdinP(timeLimit, message, color) {

@@ -167,2 +139,8 @@ var deferred = Q.defer();

Object.keys(val).sort().forEach(function(key) {
if (typeof val[key] === "function") {
// Silently ignore nested methods, but nevertheless
// complain below if the root value is a function.
return;
}
hash.update(key + "\0")

@@ -379,1 +357,8 @@ .update(deepHash(val[key]));

exports.waitForValuesP = waitForValuesP;
function camelize(hyphenated) {
return hyphenated.replace(/-(.)/g, function(_, ch) {
return ch.toUpperCase();
});
}
exports.camelize = camelize;

@@ -17,3 +17,3 @@ {

],
"version": "0.8.15",
"version": "0.9.0",
"license": "MIT",

@@ -20,0 +20,0 @@ "homepage": "http://github.com/benjamn/commoner",

@@ -366,4 +366,6 @@ Commoner [![Build Status](https://travis-ci.org/benjamn/commoner.png?branch=master)](https://travis-ci.org/benjamn/commoner)

).process(function(id, source) {
this.options.customOption // Access the option
return …;
if (this.options.customOption) {
source = doCustomThing(source);
}
return source;
});

@@ -370,0 +372,0 @@ ```

@@ -23,8 +23,10 @@ var Watcher = require("../lib/watcher").Watcher;

var debugContext = new BuildContext({
debug: true
}, null, new ReadFileCache(sourceDir));
config: { debug: true },
sourceDir: sourceDir
}, new ReadFileCache(sourceDir));
var releaseContext = new BuildContext({
debug: false
}, null, new ReadFileCache(sourceDir));
config: { debug: false },
sourceDir: sourceDir
}, new ReadFileCache(sourceDir));

@@ -31,0 +33,0 @@ debugContext.setCacheDirectory(path.join(

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