Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

test/fixtures/banner2.js

34

lib/grunt/template.js

@@ -14,12 +14,36 @@ /*

exports.formatToday = function(format) {
exports.today = function(format) {
return dateformat(new Date(), format);
};
exports.joinItems = function(items, separator) {
return items.join(typeof separator === 'string' ? separator : ', ');
exports.stripBanner = function(src) {
return src.replace(/^\s*\/\*[^!][\s\S]*?\*\/\s*/, '');
};
exports.stripBanner = function(src) {
return src.replace(/^\s*\/\*[\s\S]*?\*\/\s*/, '');
// Set underscore template delimiters.
exports.delimiters = function(mode) {
var modes = {
// The underscore default template syntax should be a pretty sane default.
default: {
evaluate: /<%([\s\S]+?)%>/g,
interpolate: /<%=([\s\S]+?)%>/g,
escape: /<%-([\s\S]+?)%>/g
},
// The "init" task needs separate delimiters to avoid conflicts, so the <>
// are replaced with {}. Otherwise, they behave the same.
init: {
evaluate: /\{%([\s\S]+?)%\}/g,
interpolate: /\{%=([\s\S]+?)%\}/g,
escape: /\{%-([\s\S]+?)%\}/g
}
};
underscore.templateSettings = modes[mode in modes ? mode : 'default'];
};
// Process template + data with underscore.
exports.process = function(template, data, mode) {
// Set delimiters if necessary.
exports.delimiters(mode);
// Render and return template.
return underscore.template(template)(data);
};

5

package.json
{
"name": "grunt",
"description": "A command line build tool for JavaScript projects.",
"version": "0.2.0",
"version": "0.2.1",
"author": "\"Cowboy\" Ben Alman (http://benalman.com/)",

@@ -26,3 +26,3 @@ "homepage": "http://github.com/cowboy/grunt",

"engines": {
"node": ">= 0.4.12"
"node": ">= 0.6.0"
},

@@ -47,3 +47,2 @@ "preferGlobal": true,

"glob-whatev": "~0.1.0",
"handlebars": "1.0.2beta",
"jshint": "~0.5",

@@ -50,0 +49,0 @@ "nodeunit": "~0.6.4",

@@ -321,4 +321,47 @@ # grunt

## Predefined Tasks
### concat
#### Concatenate files.
In the following example
```javascript
config.init({
pkg: '<json:package.json>',
meta: {
banner: '/*! {%= pkg.name %} - v{%= pkg.version %} - {%= template.today("m/d/yyyy") %}\n' +
'* {%= pkg.homepage %}\n' +
'* Copyright (c) {%= template.today("yyyy") %} {%= pkg.author.name %};' +
' Licensed {%= _.pluck(pkg.licenses, "type").join(", ") %} */'
},
concat: {
'dist/concat.js': ['lib/file1.js', 'lib/file2.js'],
'dist/concat_w_banner.js': ['<banner>', '<file_strip_banner:lib/file1.js>', '<file_strip_banner:lib/file2.js>'],
}
});
```
### init
#### Generate project scaffolding based on user input.
### lint
#### Validate files with [JSHint][jshint].
### min
#### Minify files with [UglifyJS][uglify].
### test
#### Run unit tests with [nodeunit][nodeunit].
### watch
#### Run predefined tasks whenever watched files change.
## Global Variables
In an effort to make things easier, there are a lot of global variables.
In an effort to make things easier, there are a lot of global variables. Feel free to use them in any of your tasks. Just look at other tasks to see how they're used, before you go crazy with them.

@@ -438,6 +481,7 @@ * `underscore` - [Underscore.js](http://underscorejs.org/)

## Release History
_(For now, this will only be updated for v0.x releases, not v0.x.x releases)_
_(Until v1.0.0, this will only be updated when major or breaking changes are made)_
2012/01/22 - v0.2.0 - Added "init" task with a sample template, reworked a lot of code. Hopefully it's backwards-compatible.
2012/01/11 - v0.1.0 - Initial release.
* 2012/01/22 - v0.2.1 - Removed handlebars, templates are universally handled by underscore now. Changed init task template tags from <% %> to {% %}. Banners beginning with /*! will no longer be stripped.
* 2012/01/22 - v0.2.0 - Added "init" task with a sample template, reworked a lot of code. Hopefully it's backwards-compatible.
* 2012/01/11 - v0.1.0 - Initial release.

@@ -444,0 +488,0 @@ ## License

@@ -152,3 +152,3 @@ /*

init.copy(files.src, files.dest || files.src, function(contents) {
return underscore.template(contents)(props);
return template.process(contents, props, 'init');
});

@@ -166,7 +166,8 @@ });

// Author.
if ('author_name' in props) {
pkg.author = props.author_name;
if (props.author_email) { pkg.author += ' <' + props.author_email + '>'; }
if (props.author_url) { pkg.author += ' (' + props.author_url + ')'; }
}
['name', 'email', 'url'].forEach(function(prop) {
if (props['author_' + prop]) {
if (!pkg.author) { pkg.author = {}; }
pkg.author[prop] = props['author_' + prop];
}
});
// Other stuff.

@@ -173,0 +174,0 @@ if ('repository' in props) { pkg.repository = {type: 'git', url: props.repository}; }

/*
* <%= name %>
* <%= homepage %>
* {%= name %}
* {%= homepage %}
*
* Copyright (c) <% print(template.formatToday('yyyy')) %> <%= author_name %>
* Licensed under the <% print(licenses.join(', ')) %> license<% print(licenses.length === 1 ? '' : 's') %>.
* Copyright (c) {%= template.today('yyyy') %} {%= author_name %}
* Licensed under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.
*/

@@ -8,0 +8,0 @@

@@ -1,11 +0,11 @@

# <%= name %>
# {%= name %}
<%= description %>
{%= description %}
## Getting Started
Install the module with: `npm install <%= name %>`
Install the module with: `npm install {%= name %}`
```javascript
var <%= js_safe_name %> = require('<%= name %>');
<%= js_safe_name %>.awesome(); // "awesome"
var {%= js_safe_name %} = require('{%= name %}');
{%= js_safe_name %}.awesome(); // "awesome"
```

@@ -26,3 +26,3 @@

## License
Copyright (c) <% print(template.formatToday('yyyy')) %> <%= author_name %>
Licensed under the <% print(licenses.join(', ')) %> license<% print(licenses.length === 1 ? '' : 's') %>.
Copyright (c) {%= template.today('yyyy') %} {%= author_name %}
Licensed under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.

@@ -1,2 +0,2 @@

var <%= js_safe_name %> = require('../lib/<%= name %>.js');
var {%= js_safe_name %} = require('../lib/{%= name %}.js');

@@ -11,5 +11,5 @@ exports['awesome'] = {

// tests here
test.equal(<%= js_safe_name %>.awesome(), 'awesome', 'should be awesome.');
test.equal({%= js_safe_name %}.awesome(), 'awesome', 'should be awesome.');
test.done();
}
};

@@ -11,3 +11,2 @@ /*

var spawn = require('child_process').spawn;
var handlebars = require('handlebars');

@@ -54,6 +53,6 @@ // ============================================================================

var banner, obj;
var template = config(prop);
if (template) {
var tmpl = config(prop);
if (tmpl) {
// Read config object first, to ensure that verbose-mode JSON reading via
// <json> directive doesn't interrupt future logging.
// <json> directive doesn't interrupt logging.
obj = config();

@@ -64,3 +63,3 @@ // Now, log.

// Compile and run template, passing in config object as the data source.
banner = handlebars.compile(template)(obj) + '\n';
banner = template.process(tmpl, obj) + '\n';
verbose.ok();

@@ -70,4 +69,3 @@ } catch(e) {

verbose.error();
log.error(e.message);
fail.warn('Handlebars found errors.', 11);
fail.warn(e, 11);
}

@@ -80,5 +78,1 @@ } else {

});
// Banner helpers.
handlebars.registerHelper('today', template.formatToday);
handlebars.registerHelper('join', template.joinItems);

Sorry, the diff of this file is not supported yet

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