Socket
Socket
Sign inDemoInstall

jake

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jake - npm Package Compare versions

Comparing version 0.2.15 to 0.2.18

11

lib/api.js

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

this.fail = function (err, code) {
var msg
, errObj;
if (code) {

@@ -71,3 +73,10 @@ jake.errorCode = code;

if (typeof err == 'string') {
throw new Error(err);
// Use the initial or only line of the error as the error-message
// If there was a multi-line error, use the rest as the stack
msg = err.split('/n');
errObj = new Error(msg.shift());
if (msg.length) {
errObj.stack = msg.join('\n');
}
throw errObj;
}

@@ -74,0 +83,0 @@ else if (err instanceof Error) {

10

lib/file_list.js

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

catch(e) {
fail('FileList requires minimatch ' +
'(https://github.com/isaacs/minimatch). Try `npm install -g minimatch`.');
// Hacky fallback, assume global install at /usr/local?
try {
minimatch = require('/usr/local/lib/node_modules/minimatch');
}
catch(e) {
fail('FileList requires minimatch ' +
'(https://github.com/isaacs/minimatch). Try `npm install -g minimatch`.');
}
}

@@ -95,0 +101,0 @@ }

@@ -46,51 +46,51 @@ /*

task('version', function () {
var cmds
, path = process.cwd() + '/package.json'
, pkg = getPackage()
, version = pkg.version
, arr = version.split('.')
, patch
, message;
// Only bump, push, and tag if the Git repo is clean
exec('git status --porcelain --untracked-files=no',
function (err, stdout, stderr) {
var cmds
, path
, pkg
, version
, arr
, patch
, message;
// Increment the patch-number for the version
patch = parseInt(arr.pop(), 10) + 1
arr.push(patch);
version = arr.join('.');
pkg.version = version;
message = 'Version ' + version
if (err) {
fail(err);
}
if (stderr) {
fail(new Error(stderr));
}
if (stdout.length) {
fail(new Error('Git repository is not clean.'));
}
// Update package.json with the new version-info
fs.writeFileSync(path, JSON.stringify(pkg, true, 2));
// Grab the current version-string
path = process.cwd() + '/package.json';
pkg = getPackage();
version = pkg.version;
// Increment the patch-number for the version
arr = version.split('.');
patch = parseInt(arr.pop(), 10) + 1;
arr.push(patch);
version = arr.join('.');
// New package-version
pkg.version = version;
// Commit-message
message = 'Version ' + version
// Add the version-bump commit
cmds = [
'git commit package.json -m "' + message + '"'
];
jake.exec(cmds, function () {
// Only push and tag if the Git repo is clean
exec('git status --porcelain --untracked-files=no',
function (err, stdout, stderr) {
var cmds;
if (err) {
throw err;
return;
}
if (stderr) {
throw new Error(stderr);
return;
}
if (stdout.length) {
throw new Error('Git repository is not clean.');
return;
}
cmds = [
'git push origin master'
, 'git tag -a v' + version + ' -m "' + message + '"'
, 'git push --tags'
];
jake.exec(cmds, function () {
var version = getPackageVersionNumber();
console.log('Bumped version number to v' + version + '.');
complete();
});
// Update package.json with the new version-info
fs.writeFileSync(path, JSON.stringify(pkg, true, 2));
cmds = [
'git commit package.json -m "' + message + '"'
, 'git push origin master'
, 'git tag -a v' + version + ' -m "' + message + '"'
, 'git push --tags'
];
jake.exec(cmds, function () {
var version = getPackageVersionNumber();
console.log('Bumped version number to v' + version + '.');
complete();
});

@@ -97,0 +97,0 @@ });

@@ -6,3 +6,7 @@ var DirectoryTask

this.modTime = null;
this.constructor.prototype.initialize.apply(this, arguments);
// Do constructor-work only on actual instances, not when used
// for inheritance
if (arguments.length) {
this.constructor.prototype.init.apply(this, arguments);
}
};

@@ -9,0 +13,0 @@ DirectoryTask.prototype = new FileTask();

@@ -95,3 +95,7 @@ var fs = require('fs')

this.modTime = null;
this.constructor.prototype.initialize.apply(this, arguments);
// Do constructor-work only on actual instances, not when used
// for inheritance
if (arguments.length) {
this.constructor.prototype.init.apply(this, arguments);
}
};

@@ -98,0 +102,0 @@ FileTask.prototype = new Task();

@@ -13,3 +13,7 @@ var fs = require('fs')

Task = function () {
this.constructor.prototype.initialize.apply(this, arguments);
// Do constructor-work only on actual instances, not when used
// for inheritance
if (arguments.length) {
this.constructor.prototype.init.apply(this, arguments);
}
};

@@ -36,3 +40,3 @@

this.initialize = function (name, prereqs, action, options) {
this.init = function (name, prereqs, action, options) {
var opts = options || {};

@@ -39,0 +43,0 @@

@@ -21,6 +21,42 @@ /*

var exec = require('child_process').exec
, spawn = require('child_process').spawn
, utils;
utils = new (function () {
var _mix = function (targ, src, merge, includeProto) {
for (var p in src) {
// Don't copy stuff from the prototype
if (src.hasOwnProperty(p) || includeProto) {
if (merge &&
// Assumes the source property is an Object you can
// actually recurse down into
(typeof src[p] == 'object') &&
(src[p] !== null) &&
!(src[p] instanceof Array)) {
// Create the source property if it doesn't exist
// TODO: What if it's something weird like a String or Number?
if (typeof targ[p] == 'undefined') {
targ[p] = {};
}
_mix(targ[p], src[p], merge, includeProto); // Recurse
}
// If it's not a merge-copy, just set and forget
else {
targ[p] = src[p];
}
}
}
}
, _trim = function (s) {
var str = s || '';
return str.replace(/^\s*|\s*$/g, '');
}
, _truncate = function (s) {
var str = s ? s.replace(/\n$/, '') : '';
return str;
};
this.exec = function (arr, callback, opts) {

@@ -36,15 +72,48 @@ var options = opts || {}

run = function () {
var next = list.shift();
var sh
, cmd
, args
, next = list.shift()
, errData = '';
// Keep running as long as there are commands in the array
if (next) {
exec(next, function (err, stdout, stderr) {
if (err && breakOnError) {
this.fail('Error: ' + JSON.stringify(err));
// Ganking part of Node's child_process.exec to get cmdline args parsed
if (process.platform == 'win32') {
cmd = 'cmd.exe';
// TODO: Escape double-quotes?
args = ['/s', '/c', '"' + next + '"'];
}
else {
cmd = '/bin/sh';
args = ['-c', next];
}
// Spawn a child-process, set up output
sh = spawn(cmd, args);
// Out
if (stdout) {
sh.stdout.on('data', function (data) {
console.log(_truncate(data.toString()));
});
}
// Err
sh.stderr.on('data', function (data) {
var d = data.toString();
if (stderr) {
console.error(_truncate(d));
}
if (stderr && options.stderr) {
console.log('Error: ' + stderr);
// Accumulate the error-data so we can use it as the
// stack if the process exits with an error
errData += d;
});
// Exit, handle err or run next
sh.on('exit', function (code) {
var msg = errData || 'Process exited with error.';
msg = _trim(msg);
if (breakOnError && code != 0) {
fail(msg, code);
}
if (stdout && options.stdout) {
console.log(stdout);
else {
run();
}
run();
});

@@ -62,27 +131,2 @@ }

var _mix = function (targ, src, merge, includeProto) {
for (var p in src) {
// Don't copy stuff from the prototype
if (src.hasOwnProperty(p) || includeProto) {
if (merge &&
// Assumes the source property is an Object you can
// actually recurse down into
(typeof src[p] == 'object') &&
(src[p] !== null) &&
!(src[p] instanceof Array)) {
// Create the source property if it doesn't exist
// TODO: What if it's something weird like a String or Number?
if (typeof targ[p] == 'undefined') {
targ[p] = {};
}
_mix(targ[p], src[p], merge, includeProto); // Recurse
}
// If it's not a merge-copy, just set and forget
else {
targ[p] = src[p];
}
}
}
};
this.objectToString = function (object) {

@@ -89,0 +133,0 @@ var objectArray = [];

{
"name": "jake",
"version": "0.2.15",
"description": "JavaScript build tool, similar to Make or Rake",
"keywords": [
"build",
"cli",
"make",
"rake"
],
"version": "0.2.18",
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",

@@ -5,0 +12,0 @@ "bin": {

@@ -387,2 +387,30 @@ ### Jake -- JavaScript build tool for Node.js

### Running shell-commands with `jake.exec`
Since shelling out in Node is an asynchronous operation, Jake provides a utility
function for running a sequence of shell-commands. The `jake.exec` command takes
an array of shell-command strings, and a final callback to run after completing
them. Here's an example from Jake's Jakefile, that runs the tests:
desc('Runs the Jake tests.');
task('test', function () {
var cmds = [
'node ./tests/parseargs.js'
, 'node ./tests/task_base.js'
, 'node ./tests/file_task.js'
];
jake.exec(cmds, function () {
console.log('All tests passed.');
complete();
}, {stdout: true});
}, {async: true});
It also takes an optional options-object, where you can set `stdout` (print to
stdout, default false), `stderr` (print to stderr, default false), and
`breakOnError` (stop execution on error, default true).
This command doesn't pipe input between commands -- it's for simple execution.
If you need something more sophisticated, Procstreams
(<https://github.com/polotek/procstreams>) might be a good option.
### PackageTask

@@ -389,0 +417,0 @@

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