Comparing version 1.0.0 to 1.1.0
module.exports = { | ||
realBase: require('./lib/realBase'), | ||
replaceExtension: require('./lib/replaceExtension') | ||
replaceExtension: require('./lib/replaceExtension'), | ||
colors: require('chalk'), | ||
log: require('./lib/log'), | ||
template: require('./lib/template'), | ||
env: require('optimist').argv | ||
}; |
{ | ||
"name":"gulp-util", | ||
"description":"Utility functions for gulp plugins", | ||
"version":"1.0.0", | ||
"homepage":"http://github.com/wearefractal/gulp-util", | ||
"repository":"git://github.com/wearefractal/gulp-util.git", | ||
"author":"Fractal <contact@wearefractal.com> (http://wearefractal.com/)", | ||
"main":"./index.js", | ||
"devDependencies":{ | ||
"mocha":"*", | ||
"should":"*" | ||
}, | ||
"scripts":{ | ||
"test":"mocha" | ||
}, | ||
"engines":{ | ||
"node":">= 0.4.0" | ||
}, | ||
"licenses":[ | ||
{ | ||
"type":"MIT", | ||
"url":"http://github.com/wearefractal/gulp-util/raw/master/LICENSE" | ||
} | ||
] | ||
"name": "gulp-util", | ||
"description": "Utility functions for gulp plugins", | ||
"version": "1.1.0", | ||
"homepage": "http://github.com/wearefractal/gulp-util", | ||
"repository": "git://github.com/wearefractal/gulp-util.git", | ||
"author": "Fractal <contact@wearefractal.com> (http://wearefractal.com/)", | ||
"main": "./index.js", | ||
"dependencies": { | ||
"chalk": "~0.3.0", | ||
"lodash.template": "~2.4.1", | ||
"optimist": "~0.6.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"should": "*" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"engines": { | ||
"node": ">= 0.4.0" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://github.com/wearefractal/gulp-util/raw/master/LICENSE" | ||
} | ||
] | ||
} |
@@ -22,8 +22,40 @@ ![status](https://secure.travis-ci.org/wearefractal/gulp-util.png?branch=master) | ||
```javascript | ||
var util = require('gulp-util'); | ||
var gutil = require('gulp-util'); | ||
util.replaceExtension("file.coffee", ".js"); // file.js | ||
util.realBase("/home/contra/test/whatever/huh/file.js", "/home/contra/test"); // /whatever/huh/file.js | ||
gutil.log("stuff happened", "Really it did", gulp.colors.cyan("123")); | ||
gutil.replaceExtension("file.coffee", ".js"); // file.js | ||
gutil.realBase("/home/contra/test/whatever/huh/file.js", "/home/contra/test"); // /whatever/huh/file.js | ||
var opt = { | ||
name: "todd", | ||
file: someGulpFile | ||
}; | ||
gutil.template("test <%= name %> <%= file.path %>", opt) // test todd /js/hi.js | ||
``` | ||
### log(msg...) | ||
Logs stuff. Already prefixed with [gulp] and all that. Use the right colors for values. If you pass in multiple arguments it will join them by a space. | ||
``` | ||
values (files, module names, etc.) = magenta | ||
numbers (times, counts, etc) = cyan | ||
``` | ||
### colors | ||
This is an instance of [chalk](https://github.com/sindresorhus/chalk) | ||
### replaceExtension(path, newExtension) | ||
Replaces a file extension in a path. Returns the new path. | ||
### realBase(baseDir, path) | ||
Returns a pretty base path. | ||
### template(string[, data]) | ||
This is a lodash.template function wrapper. You must pass in a valid gulp file object so it is available to the user or it will error. You can not configure any of the delimiters. Look at the [lodash docs](http://lodash.com/docs#template) for more info. | ||
## LICENSE | ||
@@ -30,0 +62,0 @@ |
@@ -7,2 +7,65 @@ var util = require('../'); | ||
describe('gulp-util', function() { | ||
describe('colors', function(){ | ||
it('should be a chalk instance', function(done){ | ||
util.colors.should.equal(require('chalk')); | ||
done(); | ||
}); | ||
}); | ||
describe('log()', function(){ | ||
it('should work i guess', function(done){ | ||
util.log(1, 2, 3, 4, "five"); | ||
done(); | ||
}); | ||
}); | ||
describe('template()', function(){ | ||
it('should work with just a template', function(done){ | ||
var opt = { | ||
name:"todd", | ||
file: { | ||
path: "hi.js" | ||
} | ||
}; | ||
var expected = "test todd hi.js"; | ||
var tmpl = util.template('test <%= name %> <%= file.path %>'); | ||
should.exist(tmpl); | ||
'function'.should.equal(typeof(tmpl)); | ||
// eval it now | ||
var etmpl = tmpl(opt); | ||
'string'.should.equal(typeof(etmpl)); | ||
etmpl.should.equal(expected); | ||
done(); | ||
}); | ||
it('should work with a template and data', function(done){ | ||
var opt = { | ||
name:"todd", | ||
file: { | ||
path: "hi.js" | ||
} | ||
}; | ||
var expected = "test todd hi.js"; | ||
var tmpl = util.template('test <%= name %> <%= file.path %>', opt); | ||
should.exist(tmpl); | ||
'string'.should.equal(typeof(tmpl)); | ||
tmpl.should.equal(expected); | ||
done(); | ||
}); | ||
it('should throw an error when no file object is passed', function(done){ | ||
var opt = { | ||
name:"todd" | ||
}; | ||
try { | ||
var tmpl = util.template('test <%= name %> <%= file.path %>', opt); | ||
} catch (err) { | ||
should.exist(err); | ||
done(); | ||
} | ||
}); | ||
}); | ||
describe('realBase()', function() { | ||
@@ -9,0 +72,0 @@ it('should return a valid shortened name', function(done) { |
8467
11
122
84
3
+ Addedchalk@~0.3.0
+ Addedlodash.template@~2.4.1
+ Addedoptimist@~0.6.0
+ Addedansi-styles@0.2.0(transitive)
+ Addedchalk@0.3.0(transitive)
+ Addedhas-color@0.1.7(transitive)
+ Addedlodash._escapehtmlchar@2.4.1(transitive)
+ Addedlodash._escapestringchar@2.4.1(transitive)
+ Addedlodash._htmlescapes@2.4.1(transitive)
+ Addedlodash._isnative@2.4.1(transitive)
+ Addedlodash._objecttypes@2.4.1(transitive)
+ Addedlodash._reinterpolate@2.4.1(transitive)
+ Addedlodash._reunescapedhtml@2.4.1(transitive)
+ Addedlodash._shimkeys@2.4.1(transitive)
+ Addedlodash.defaults@2.4.1(transitive)
+ Addedlodash.escape@2.4.1(transitive)
+ Addedlodash.isobject@2.4.1(transitive)
+ Addedlodash.keys@2.4.1(transitive)
+ Addedlodash.template@2.4.1(transitive)
+ Addedlodash.templatesettings@2.4.1(transitive)
+ Addedlodash.values@2.4.1(transitive)
+ Addedminimist@0.0.10(transitive)
+ Addedoptimist@0.6.1(transitive)
+ Addedwordwrap@0.0.3(transitive)