New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-util

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-util - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/log.js

6

index.js
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
};

52

package.json
{
"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) {

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