Skip to content

Commit

Permalink
Test on Node 5, drop Node 0.10, update deps, bump version to 0.12.0-pre
Browse files Browse the repository at this point in the history
  • Loading branch information
mgol committed Oct 29, 2015
1 parent 121a66f commit 1577ef7
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 52 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// Rules are divided into sections from http://eslint.org/docs/rules/

// ECMAScript 6
"prefer-spread": 0, // TODO enable in Node 5 or 6
"prefer-reflect": 0 // TODO enable when Node supports it
}
}
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
language: node_js
sudo: false
node_js:
- '0.10'
- '0.12'
- '4'
- '5'
before_install:
# Prevent Bower from asking questions.
- export CI=true
# Log HTTP requests
- npm config set loglevel http
# Update npm on Node 0.10; default is too old
- if [ "`node --version | cut -f1-2 -d.`" == "v0.10" ]; then npm -g install npm; fi
install:
- time npm install
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// Disable options that don't work in Node.js 0.10.
// Disable options that don't work in Node.js 0.12.
// Gruntfile.js & tasks/*.js are the only non-transpiled files.
/* eslint-disable no-var, object-shorthand, prefer-arrow-callback, prefer-const,
prefer-spread, prefer-reflect, prefer-template */
Expand All @@ -9,7 +9,7 @@ var assert = require('assert');

var newNode;
try {
assert.strictEqual(eval('(() => 2)()'), 2); // eslint-disable-line no-eval
assert.strictEqual(eval('(r => [...r])([2])[0]'), 2); // eslint-disable-line no-eval
newNode = true;
} catch (e) {
newNode = false;
Expand Down Expand Up @@ -67,7 +67,7 @@ module.exports = function (grunt) {
// 'es6.parameters',
'es6.properties.computed',
'es6.properties.shorthand',
// 'es6.spread',
'es6.spread',
// 'es6.tailCall',
'es6.templateLiterals',
// 'es6.regex.unicode',
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ require('check-dependencies')({}, callback);
behave in the same way - `callback` is invoked upon completion; if there was an error, it's passed as a parameter to `callback`.

## Supported Node.js versions
This project aims to support all Node.js LTS versions in the "active" phase (see [LTS README](https://github.com/nodejs/LTS/blob/master/README.md) for more details) as well as the latest stable Node.js. Today that means Node.js 0.12 & 4.x.

Because of the popularity of this package and Node.js 0.10, this version is temporarily supported as well.
This project aims to support all Node.js LTS versions in the "active" phase (see [LTS README](https://github.com/nodejs/LTS/blob/master/README.md) for more details) as well as the latest stable Node.js. Today that means Node.js 0.12, 4 & 5.

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using `npm test`.
Expand Down
2 changes: 1 addition & 1 deletion bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict';

// Disable options that don't work in Node.js 0.10.
// Disable options that don't work in Node.js 0.12.
// Gruntfile.js & tasks/*.js are the only non-transpiled files.
/* eslint-disable no-var */

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

// Disable options that don't work in Node.js 0.10.
// Disable options that don't work in Node.js 0.12.
// Gruntfile.js & tasks/*.js are the only non-transpiled files.
/* eslint-disable no-var, no-eval */

var assert = require('assert');

try {
assert.strictEqual(eval('(() => 2)()'), 2);
assert.strictEqual(eval('(r => [...r])([2])[0]'), 2);
module.exports = require('./lib/check-dependencies');
} catch (e) {
module.exports = require('./dist/lib/check-dependencies');
Expand Down
28 changes: 11 additions & 17 deletions lib/check-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const chalk = require('chalk');
const findup = require('findup-sync');
const _ = require('lodash');
const semver = require('semver');
const Promise = require('bluebird'); // TODO remove when Node.js 0.10 is dropped
const spawn = require('child_process').spawn;
const spawnSync = require('child_process').spawnSync;

Expand All @@ -29,15 +28,15 @@ const checkDependenciesHelper = (syncOrAsync, config, callback) => {
config = null;
}
if (typeof callback !== 'function') {
if (callback != null) {
if (callback == null) {
// In the async mode we return the promise anyway; assign callback
// to noop to keep code consistency.
callback = _.noop;
} else {
// If callback was simply not provided, we assume the user wanted
// to handle the returned promise. If it was passed but not a function
// we assume user error and throw.
throw new Error('The provided callback wasn\'t a function! Got:', callback);
} else {
// In the async mode we return the promise anyway; assign callback
// to noop to keep code consistency.
callback = _.noop;
}
}
}
Expand Down Expand Up @@ -187,12 +186,12 @@ const checkDependenciesHelper = (syncOrAsync, config, callback) => {
}

depVersion = require(depJson).version;
if (!semver.satisfies(depVersion, versionString)) {
success = false;
error(`${ name }: installed: ${ chalk.red(depVersion)
if (semver.satisfies(depVersion, versionString)) {
log(`${ name }: installed: ${ chalk.green(depVersion)
}, expected: ${ chalk.green(versionString) }`);
} else {
log(`${ name }: installed: ${ chalk.green(depVersion)
success = false;
error(`${ name }: installed: ${ chalk.red(depVersion)
}, expected: ${ chalk.green(versionString) }`);
}
};
Expand Down Expand Up @@ -314,11 +313,6 @@ const checkDependenciesHelper = (syncOrAsync, config, callback) => {
const installMissing = () => installOrPrune('install');
const pruneExcessive = () => installOrPrune('prune');

if (syncOrAsync !== 'sync') {
// TODO disable it in a more clever way?
Promise.onPossiblyUnhandledRejection();
}

if (syncOrAsync === 'sync') {
try {
if (installNeeded) {
Expand Down Expand Up @@ -359,7 +353,7 @@ const checkDependenciesHelper = (syncOrAsync, config, callback) => {
module.exports = function checkDependencies(/* config, callback */) {
const args = Array.prototype.slice.call(arguments);
args.unshift('async');
return checkDependenciesHelper.apply(null, args);
return checkDependenciesHelper(...args);
};

module.exports.sync = function checkDependenciesSync(/* config */) {
Expand All @@ -372,5 +366,5 @@ module.exports.sync = function checkDependenciesSync(/* config */) {
}
const args = Array.prototype.slice.call(arguments);
args.unshift('sync');
return checkDependenciesHelper.apply(null, args);
return checkDependenciesHelper(...args);
};
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "check-dependencies",
"version": "0.11.1-pre",
"version": "0.12.0-pre",
"description": "Checks if currently installed npm/bower dependencies are installed in the exact same versions that are specified in package.json/bower.json",
"homepage": "https://github.com/mzgol/check-dependencies",
"author": {
Expand Down Expand Up @@ -31,29 +31,29 @@
"dist/lib"
],
"dependencies": {
"bluebird": "^2.10.0",
"bower-config": "^0.6.1",
"bower-config": "^1.2.2",
"chalk": "^1.1.1",
"findup-sync": "^0.3.0",
"lodash": "^3.10.1",
"minimist": "^1.2.0",
"semver": "^5.0.3"
},
"devDependencies": {
"bower": "1.5.2",
"eslint-config-mzgol": "0.0.3",
"fs-extra": "0.24.0",
"bluebird": "3.0.2",
"bower": "1.6.5",
"eslint-config-mzgol": "0.0.6",
"fs-extra": "0.26.0",
"grunt": "0.4.5",
"grunt-babel": "5.0.1",
"grunt-babel": "5.0.3",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-copy": "0.8.1",
"grunt-eslint": "17.1.0",
"grunt-contrib-copy": "0.8.2",
"grunt-eslint": "17.3.1",
"grunt-mocha-test": "0.12.7",
"load-grunt-tasks": "3.2.0",
"mocha": "2.3.2",
"sinon": "1.16.1",
"time-grunt": "1.2.1"
"load-grunt-tasks": "3.3.0",
"mocha": "2.3.3",
"sinon": "1.17.2",
"time-grunt": "1.2.2"
},
"scripts": {
"test": "grunt"
Expand Down
18 changes: 9 additions & 9 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ describe('checkDependencies', () => {
}

if (checkDependenciesMode === 'callbacks') {
checkDependencies.apply(null, args);
checkDependencies(...args);
}
if (checkDependenciesMode === 'promises') {
callback = args.pop();
checkDependencies.apply(null, args)
checkDependencies(...args)
.then(output => {
callback(output);
})
Expand All @@ -49,7 +49,7 @@ describe('checkDependencies', () => {
}
if (checkDependenciesMode === 'sync') {
callback = args.pop();
callback(checkDependencies.sync.apply(null, args));
callback(checkDependencies.sync(...args));
}
};
};
Expand Down Expand Up @@ -418,7 +418,9 @@ describe('checkDependencies', () => {
it('should check custom package name dependencies only if `checkCustomPackageNames` ' +
'is true and we are testing bower, not npm', done => {

if (packageManager !== 'npm') {
if (packageManager === 'npm') {
done();
} else {

checkDeps({
checkCustomPackageNames: true,
Expand All @@ -443,14 +445,14 @@ describe('checkDependencies', () => {
done();
});

} else {
done();
}
});

it('should find no errors if checkCustomPackageNames=true and custom package names are ok',
done => {
if (packageManager !== 'npm') {
if (packageManager === 'npm') {
done();
} else {
checkDeps({
checkCustomPackageNames: true,
packageDir: `${ __dirname }/bower-fixtures/custom-package-ok`,
Expand All @@ -462,8 +464,6 @@ describe('checkDependencies', () => {
done();
});

} else {
done();
}
});

Expand Down

0 comments on commit 1577ef7

Please sign in to comment.