Comparing version 0.8.12 to 0.8.13
@@ -28,2 +28,3 @@ var assert = require("assert"); | ||
customVersion: { value: null, writable: true }, | ||
customOptions: { value: [] }, | ||
resolvers: { value: [] }, | ||
@@ -41,2 +42,8 @@ processors: { value: [] } | ||
// Add custom command line options | ||
Cp.option = function() { | ||
this.customOptions.push(Ap.slice.call(arguments)); | ||
return this; // For chaining. | ||
}; | ||
// A resolver is a function that takes a module identifier and returns | ||
@@ -66,3 +73,3 @@ // the unmodified source of the corresponding module, either as a string | ||
Cp.buildP = function(config, sourceDir, outputDir, roots) { | ||
Cp.buildP = function(config, options, sourceDir, outputDir, roots) { | ||
var self = this; | ||
@@ -107,3 +114,3 @@ var readFileCache = new ReadFileCache(sourceDir); | ||
var context = new BuildContext(config, readFileCache); | ||
var context = new BuildContext(config, options, readFileCache); | ||
@@ -221,5 +228,10 @@ if (self.preferredFileExtension) | ||
.option("--cache-dir <directory>", "Alternate directory to use for disk cache") | ||
.option("--no-cache-dir", "Disable the disk cache") | ||
.parse(process.argv.slice(0)); | ||
.option("--no-cache-dir", "Disable the disk cache"); | ||
commoner.customOptions.forEach(function(customOption) { | ||
options.option.apply(options, customOption); | ||
}); | ||
options.parse(process.argv.slice(0)); | ||
var pfe = new PreferredFileExtension(options.extension || "js"); | ||
@@ -306,2 +318,3 @@ | ||
}), | ||
options, | ||
sourceDir, | ||
@@ -308,0 +321,0 @@ outputDir, |
@@ -11,3 +11,3 @@ var assert = require("assert"); | ||
function BuildContext(config, readFileCache) { | ||
function BuildContext(config, options, readFileCache) { | ||
var self = this; | ||
@@ -23,2 +23,3 @@ assert.ok(self instanceof BuildContext); | ||
config: { value: config }, | ||
options: { value: options }, | ||
configHash: { value: util.deepHash(config) } | ||
@@ -25,0 +26,0 @@ }); |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "0.8.12", | ||
"version": "0.8.13", | ||
"license": "MIT", | ||
@@ -20,0 +20,0 @@ "homepage": "http://github.com/benjamn/commoner", |
@@ -303,1 +303,20 @@ Commoner [![Build Status](https://travis-ci.org/benjamn/commoner.png?branch=master)](https://travis-ci.org/benjamn/commoner) | ||
have distinct hashes if built using different configuration objects. | ||
Custom Options | ||
--- | ||
You can define custom options for your script by using the `option` function. | ||
```js | ||
require("commoner").resolve(function(id) { | ||
return this.readModule(id); | ||
}).option( | ||
'--custom-option', | ||
'This is a custom option.' | ||
).process(function(id, source) { | ||
this.options.customOption // Access the option | ||
return …; | ||
}); | ||
``` | ||
For more information of the options object available inside the `process` function see [Commander](https://github.com/visionmedia/commander.js). |
@@ -24,7 +24,7 @@ var Watcher = require("../lib/watcher").Watcher; | ||
debug: true | ||
}, new ReadFileCache(sourceDir)); | ||
}, null, new ReadFileCache(sourceDir)); | ||
var releaseContext = new BuildContext({ | ||
debug: false | ||
}, new ReadFileCache(sourceDir)); | ||
}, null, new ReadFileCache(sourceDir)); | ||
@@ -31,0 +31,0 @@ debugContext.setCacheDirectory(path.join( |
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
87151
2109
322