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.1.2 to 0.2.0

tasks/concat.js

8

grunt.js

@@ -8,3 +8,3 @@ /*global config:true, task:true*/

lint: {
files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
files: ['grunt.js', 'lib/**/*.js', 'tasks/*.js', 'test/**/*.js']
},

@@ -27,8 +27,9 @@ watch: {

eqnull: true,
node: true
node: true,
es5: true
},
globals: {
grunt: true,
grequire: true,
urequire: true,
extraspath: true,
underscore: true,

@@ -41,2 +42,3 @@ util: true,

option: true,
template: true,
log: true,

@@ -43,0 +45,0 @@ verbose: true

@@ -16,4 +16,2 @@ /*

global.urequire = function(libname) { return require(path.join(__dirname, 'util', libname)); };
// Used to access task "extras" files.
global.extraspath = function(taskname) { return path.resolve(__dirname, '..', 'extras', taskname); };
// Some useful globals. I'm lazy.

@@ -27,5 +25,14 @@ global.underscore = require('underscore');

global.option = grequire('option');
global.template = grequire('template');
global.log = grequire('log');
global.verbose = log.verbose;
global.grunt = {
version: file.readJson(path.join(__dirname, '../package.json')).version
};
// Handle exceptions.
process.on('uncaughtException', function (e) {
fail.warn(e, 3);
});
// Disable colors if --no-colors was passed.

@@ -79,11 +86,13 @@ function initColors() {

// Determine and output which tasks will be run.
var tasksSpecified = tasks && tasks.length > 0;
tasks = task.parseArgs([tasksSpecified ? tasks : 'default']);
// Initialize tasks.
task.init();
task.init(tasks);
// Determine and output which tasks will be run.
if (!tasks || tasks.length === 0) {
verbose.writeln();
if (!tasksSpecified) {
verbose.writeln('No tasks specified, running default tasks.');
tasks = 'default';
}
tasks = task.parseArgs([tasks]);
verbose.writeflags(tasks, 'Running tasks');

@@ -90,0 +99,0 @@

@@ -46,3 +46,3 @@ /*

short: 't',
info: 'Additional directory paths to scan for task files.',
info: 'Additional directory paths to scan for task files and task "extra" files.',
type: Array

@@ -49,0 +49,0 @@ },

@@ -58,4 +58,10 @@ /*

} else {
// If --debug is enabled, log the original error's stack (if it exists).
if (option('debug') && e.origError) { console.log(e.origError.stack); }
// If --debug is enabled, log the appropriate error stack (if it exists).
if (option('debug')) {
if (e.origError && e.origError.stack) {
console.log(e.origError.stack);
} else if (e.stack) {
console.log(e.stack);
}
}
// Log and exit.

@@ -62,0 +68,0 @@ log.writeln().fail('Aborted due to warnings.');

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

// Search for a filename in the given directory or all parent directories.
var root = path.resolve('/');
exports.findup = function(rootdir, filename) {

@@ -73,3 +74,3 @@ var filepath = path.join(rootdir, filename);

return filepath;
} else if (rootdir === '/') {
} else if (rootdir === root) {
return false;

@@ -114,2 +115,18 @@ } else {

// Read a file, process its content (optionally), then write the output.
exports.copy = function(srcpath, destpath, callback) {
var src = exports.read(srcpath);
if (callback) {
verbose.write('Processing source...');
try {
src = callback(src);
verbose.ok();
} catch(e) {
verbose.error();
throw task.taskError('Error while processing "' + srcpath + '" file.', e);
}
}
exports.write(destpath, src);
};
// Read a file, parse its contents, return an object.

@@ -144,1 +161,34 @@ exports.readJson = function(filepath) {

};
// Access files in the user's ".grunt" folder.
exports.userpath = function(filepath) {
var win32 = process.platform === 'win32';
var homepath = process.env[win32 ? 'USERPROFILE' : 'HOME'];
return path.resolve(homepath, '.grunt', filepath);
};
// Get a list of task paths (or task-specific extraspaths).
exports.taskpaths = function() {
var args;
var taskpaths = [];
// Path to user's "tasks" files.
taskpaths.push(exports.userpath('tasks'));
// Paths to user-specified --tasks dirs.
var optiontasks = option('tasks') ? option('tasks').slice() : [];
taskpaths = taskpaths.concat(optiontasks.map(function(relpath) {
return path.resolve(relpath);
}));
// Path to built-in task files.
taskpaths.push(path.resolve(__dirname, '../../tasks'));
// If arguments were specified, join them to pathnames.
if (arguments.length > 0) {
args = util.toArray(arguments);
taskpaths = taskpaths.map(function(dirpath) {
return path.join.apply(path, [dirpath].concat(args));
});
}
// Return only directories that actually exist!
return taskpaths.filter(function(dirpath) {
return path.existsSync(dirpath) && fs.statSync(dirpath).isDirectory();
});
};

@@ -13,3 +13,3 @@ /*

task.init(true);
task.init([], true);

@@ -16,0 +16,0 @@ var col1len = 0;

@@ -37,2 +37,4 @@ /*

task.fn = function() {
// Make a list of task-related extras paths available.
this.extraspaths = file.taskpaths.bind(file, this.name);
// Initialize the errorcount for this task.

@@ -67,2 +69,9 @@ errorcount = fail.errorcount;

// Init tasks don't require properties in config, and as such will preempt
// config loading errors.
exports.registerInitTask = function(name, info, fn) {
exports.registerTask(name, info, fn);
this._tasks[name].init = true;
};
// Override built-in registerHelper to use the registry.

@@ -120,8 +129,5 @@ exports.registerHelper = function(name, fn) {

// Initialize tasks.
exports.init = function(nofatal) {
var tasks = option('tasks') ? option('tasks').slice() : [];
// Prepend any user-specified tasks dirs with built-in tasks dir.
tasks.unshift(path.join(__dirname, 'tasks'));
exports.init = function(tasks, nocomplain) {
// Load all built-in and user-specified tasks.
tasks.forEach(function(tasksdir, i) {
file.taskpaths().reverse().forEach(function(tasksdir, i) {
try {

@@ -140,2 +146,8 @@ fs.readdirSync(tasksdir).filter(function(filename) {

// Don't complain if all specified tasks are "init" tasks.
nocomplain = nocomplain || tasks.every(function(name) {
var obj = task._taskPlusArgs(name).task;
return obj && obj.init;
});
// Get any local config data or tasks that might exist.

@@ -158,2 +170,4 @@

process.chdir(option('base') || path.dirname(configfile));
} else if (nocomplain) {
// Don't complain about missing config file.
} else if (option('config')) {

@@ -160,0 +174,0 @@ // If --config override was specified and it doesn't exist, complain.

@@ -39,5 +39,12 @@ /*

// Error constructors.
function TaskError(message) { this.message = message; }
function TaskError(message) {
this.name = 'TaskError';
this.message = message;
}
TaskError.prototype = new Error();
function HelperError(message) { this.message = message; }
function HelperError(message) {
this.name = 'HelperError';
this.message = message;
}
HelperError.prototype = new Error();

@@ -44,0 +51,0 @@

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

@@ -22,2 +22,5 @@ "repository": {

"bin": "bin/grunt",
"scripts": {
"test": "grunt test"
},
"engines": {

@@ -40,2 +43,3 @@ "node": ">= 0.4.12"

"dependencies": {
"async": "~0.1.15",
"colors": "~0.6.0",

@@ -48,2 +52,4 @@ "dateformat": "1.0.2-1.2.3",

"nopt": "~1.0.10",
"prompt": "~0.1.12",
"semver": "~1.0.13",
"uglify-js": "~1.0.7",

@@ -50,0 +56,0 @@ "underscore": "~1.2.4",

@@ -7,2 +7,3 @@ # grunt

* **concat** - Concatenate files.
* **init** - Generate project scaffolding based on user input.
* **lint** - Validate files with [JSHint][jshint].

@@ -13,3 +14,3 @@ * **min** - Minify files with [UglifyJS][uglify].

_(My TODO list includes a "project scaffolding" task as well as a "QUnit headless unit-testing" task)_
_(My TODO list includes more "project scaffolding" templates as well as a "QUnit headless unit-testing" task)_

@@ -20,8 +21,11 @@ And in addition to the predefined tasks, you can define your own.

[concat]: https://github.com/cowboy/grunt/blob/master/lib/grunt/tasks/concat.js
[lint]: https://github.com/cowboy/grunt/blob/master/lib/grunt/tasks/lint.js
[min]: https://github.com/cowboy/grunt/blob/master/lib/grunt/tasks/min.js
[test]: https://github.com/cowboy/grunt/blob/master/lib/grunt/tasks/test.js
[misc]: https://github.com/cowboy/grunt/blob/master/lib/grunt/tasks/misc.js
[tasks]: https://github.com/cowboy/grunt/tree/master/lib/grunt/tasks
[concat]: https://github.com/cowboy/grunt/blob/master/tasks/concat.js
[init]: https://github.com/cowboy/grunt/blob/master/tasks/init.js
[init-nodejs]: https://github.com/cowboy/grunt/blob/master/tasks/init/node.js
[init-nodedir]: https://github.com/cowboy/grunt/blob/master/tasks/init/node
[lint]: https://github.com/cowboy/grunt/blob/master/tasks/lint.js
[min]: https://github.com/cowboy/grunt/blob/master/tasks/min.js
[test]: https://github.com/cowboy/grunt/blob/master/tasks/test.js
[misc]: https://github.com/cowboy/grunt/blob/master/tasks/misc.js
[tasks]: https://github.com/cowboy/grunt/tree/master/tasks
[gruntfile]: https://github.com/cowboy/grunt/blob/master/grunt.js

@@ -146,3 +150,3 @@

You can go crazy with tasks, though. They don't have to be basic.
You can go crazy with tasks, though. They don't have to be basic. If your tasks don't follow the "basic task" structure, use a custom task.

@@ -212,3 +216,3 @@ ```javascript

When tasks fail, all subsequent tasks will be aborted unless `--force` is specified.
When tasks fail, all subsequent tasks will be aborted unless `--force` was specified.

@@ -313,3 +317,3 @@ ```javascript

lint: {
files: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
files: ['grunt.js', 'lib/**/*.js', 'tasks/*.js', 'test/**/*.js']
},

@@ -441,2 +445,3 @@ watch: {

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.

@@ -443,0 +448,0 @@

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