Comparing version 0.4.3 to 0.4.4
@@ -17,11 +17,11 @@ /* | ||
* @param options {Object} File options or filename. | ||
* @param options.file {Object} Filename to load. | ||
* @param options.name {Object} Filename to load. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var load = exports.load = function load(options, done) { | ||
options = (typeof options === 'string') ? {file: options} : options; | ||
options = (typeof options === 'string') ? {name: options} : options; | ||
if (options.file) { | ||
fs.readFile(options.file, function(err, data) { | ||
done(err, new Blob(data, {name: options.file})); | ||
if (options.name) { | ||
fs.readFile(options.name, function(err, data) { | ||
done(err, new Blob(data, {name: options.name})); | ||
}); | ||
@@ -31,2 +31,3 @@ } | ||
load.type = 'append'; | ||
load.browser = true; | ||
})(typeof exports === 'undefined' ? this.tasks || (this.tasks = {}) : exports); |
@@ -23,5 +23,5 @@ /* | ||
var write = exports.write = function write(options, blob, done) { | ||
options = (typeof options === 'string') ? {file: options} : options; | ||
options = (typeof options === 'string') ? {name: options} : options; | ||
var dirname = path.resolve(path.dirname(options.file)), | ||
var dirname = path.resolve(path.dirname(options.name)), | ||
checksum; | ||
@@ -35,6 +35,6 @@ | ||
if (options.file.indexOf('{checksum}') > -1) { // Replace {checksum} with md5 string | ||
if (options.name.indexOf('{checksum}') > -1) { // Replace {checksum} with md5 string | ||
checksum = Crypto.createHash('md5'); | ||
checksum.update(blob.toString()); | ||
options.file = options.file.replace('{checksum}', checksum.digest('hex')); | ||
options.name = options.name.replace('{checksum}', checksum.digest('hex')); | ||
} | ||
@@ -48,3 +48,3 @@ | ||
} else { | ||
writeFile(options.file, blob); | ||
writeFile(options.name, blob); | ||
} | ||
@@ -54,3 +54,3 @@ }); | ||
else { | ||
writeFile(options.file, blob); | ||
writeFile(options.name, blob); | ||
} | ||
@@ -57,0 +57,0 @@ }); |
{ | ||
"name": "gear", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Gear.js - Task-based build system.", | ||
@@ -5,0 +5,0 @@ "author": "Stephen Murphy <stephen@hypernaut.com>", |
@@ -40,3 +40,3 @@ # Gear.js | ||
new Queue() | ||
.load(['foo.js', {file: 'bar.js'}, 'baz.js']) | ||
.load(['foo.js', {name: 'bar.js'}, 'baz.js']) | ||
.log('read foo.js') | ||
@@ -173,2 +173,3 @@ .inspect() | ||
* options.filename - File to load tasks from. | ||
* options.tasks - Object to load tasks from. | ||
@@ -199,5 +200,6 @@ __Example__ | ||
// source - Filename or object to load. | ||
// source.file - Filename of resource. | ||
// source.name - Filename of resource. | ||
.load('foo') | ||
.load(['foo', 'baz']) | ||
.load([{file: 'foo'}, {file: 'bar'}, {file: 'baz'}]) | ||
.load([{name: 'foo'}, {name: 'bar'}, {name: 'baz'}]) | ||
``` | ||
@@ -212,3 +214,3 @@ | ||
* options.file - File to write, will replace {checksum} with hash of blob content. | ||
* options.name - File to write, will replace {checksum} with hash of blob content. | ||
@@ -220,3 +222,4 @@ Write the blob to disk. | ||
```javascript | ||
.write({file: 'foo'}) | ||
.write('foo') | ||
.write({name: 'foo'}) | ||
``` | ||
@@ -223,0 +226,0 @@ |
@@ -5,4 +5,4 @@ var should = require('should'), | ||
filename: 'test/fixtures/test1.js', | ||
file: {file: 'test/fixtures/test1.js'}, | ||
missing_file: {file: 'test/fixtures/missing_file.js'} | ||
file: {name: 'test/fixtures/test1.js'}, | ||
missing_file: {name: 'test/fixtures/missing_file.js'} | ||
}; | ||
@@ -9,0 +9,0 @@ |
@@ -5,5 +5,5 @@ var should = require('should'), | ||
fixtures = { | ||
file: {file: 'test/fixtures/test1.js'}, | ||
files: [{file: 'test/fixtures/test1.js'}, {file: 'test/fixtures/test2.js'}], | ||
missing_file: {file: 'test/fixtures/missing_file.js'} | ||
file: {name: 'test/fixtures/test1.js'}, | ||
files: [{name: 'test/fixtures/test1.js'}, {name: 'test/fixtures/test2.js'}], | ||
missing_file: {name: 'test/fixtures/missing_file.js'} | ||
}; | ||
@@ -10,0 +10,0 @@ |
@@ -6,5 +6,5 @@ var should = require('should'), | ||
fixtures = { | ||
files: [{file: 'test/fixtures/test1.js'}], | ||
missing_files: [{file: 'test/fixtures/missing_file.js'}], | ||
parallel_files: [{file: 'test/fixtures/test2.js'}] | ||
files: [{name: 'test/fixtures/test1.js'}], | ||
missing_files: [{name: 'test/fixtures/missing_file.js'}], | ||
parallel_files: [{name: 'test/fixtures/test2.js'}] | ||
}; | ||
@@ -11,0 +11,0 @@ |
@@ -30,3 +30,3 @@ var path = require('path'), | ||
remove(fixtures.filename); | ||
write({file: fixtures.filename2}, fixtures.blob, function(err, blob) { | ||
write({name: fixtures.filename2}, fixtures.blob, function(err, blob) { | ||
path.existsSync(fixtures.filename2).should.equal(true); | ||
@@ -39,3 +39,3 @@ done(err); | ||
remove(fixtures.checksum_replaced); | ||
write({file: fixtures.checksum}, fixtures.blob, function(err, blob) { | ||
write({name: fixtures.checksum}, fixtures.blob, function(err, blob) { | ||
path.existsSync(fixtures.checksum_replaced).should.equal(true); | ||
@@ -42,0 +42,0 @@ done(err); |
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
53434
1303
342