Skip to content

Commit

Permalink
Merge branch 'dev/generic-paths'
Browse files Browse the repository at this point in the history
* dev/generic-paths:
  Tools: Gulp, Grunt and NPM/APM: use '.cmd' extension
  Use generic path.set and path.join

Fixes #74
  • Loading branch information
noseglid committed May 28, 2015
2 parents f426685 + 5a12d28 commit 55e4924
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
6 changes: 4 additions & 2 deletions lib/tools/Grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ var originalNodePath = process.env.NODE_PATH;
module.exports.niceName = 'Grunt';

module.exports.isEligable = function (cwd) {
return fs.existsSync(cwd + '/Gruntfile.js');
return fs.existsSync(path.join(cwd, 'Gruntfile.js'));
};

module.exports.settings = function (cwd) {
var createConfig = function (name, args) {
var exec = fs.existsSync(cwd + '/node_modules/.bin/grunt') ? cwd + '/node_modules/.bin/grunt' : 'grunt';
var executable = /^win/.test(process.platform) ? 'grunt.cmd' : 'grunt';
var localPath = path.join(cwd, 'node_modules', '.bin', executable);
var exec = fs.existsSync(localPath) ? localPath : executable;
return {
name: name,
exec: exec,
Expand Down
9 changes: 5 additions & 4 deletions lib/tools/atom-build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
'use strict';

var path = require('path');
var fs = require('fs');
var _ = require('lodash');

module.exports.niceName = 'Custom file (.atom-build.json)';

module.exports.isEligable = function (path) {
return fs.existsSync(path + '/.atom-build.json');
module.exports.isEligable = function (cwd) {
return fs.existsSync(path.join(cwd, '.atom-build.json'));
};

module.exports.settings = function (path) {
var realAtomBuild = fs.realpathSync(path + '/.atom-build.json');
module.exports.settings = function (cwd) {
var realAtomBuild = fs.realpathSync(cwd + '/.atom-build.json');
delete require.cache[realAtomBuild];

var createBuildConfig = function(build, name) {
Expand Down
6 changes: 4 additions & 2 deletions lib/tools/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ var originalNodePath = process.env.NODE_PATH;
module.exports.niceName = 'gulp';

module.exports.isEligable = function (cwd) {
return fs.existsSync(cwd + '/gulpfile.js');
return fs.existsSync(path.join(cwd, 'gulpfile.js'));
};

module.exports.settings = function (cwd) {
var createConfig = function (name, args) {
var exec = fs.existsSync(cwd + '/node_modules/.bin/gulp') ? cwd + '/node_modules/.bin/gulp' : 'gulp';
var executable = /^win/.test(process.platform) ? 'gulp.cmd' : 'gulp';
var localPath = path.join(cwd, 'node_modules', '.bin', executable);
var exec = fs.existsSync(localPath) ? localPath : executable;
return {
name: name,
exec: exec,
Expand Down
7 changes: 4 additions & 3 deletions lib/tools/make.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

var path = require('path');
var fs = require('fs');

module.exports.niceName = 'GNU Make';

module.exports.isEligable = function (path) {
return fs.existsSync(path + '/Makefile');
module.exports.isEligable = function (cwd) {
return fs.existsSync(path.join(cwd, 'Makefile'));
};

module.exports.settings = function (path) {
module.exports.settings = function (cwd) {
return [ {
name: 'GNU Make: default',
exec: 'make',
Expand Down
14 changes: 8 additions & 6 deletions lib/tools/npm_apm.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use strict';

var path = require('path');
var fs = require('fs');

module.exports.niceName = 'npm or apm';

module.exports.isEligable = function (path) {
if (!fs.existsSync(path + '/package.json')) {
module.exports.isEligable = function (cwd) {
if (!fs.existsSync(path.join(cwd, 'package.json'))) {
return false;
}

var realPackage = fs.realpathSync(path + '/package.json');
var realPackage = fs.realpathSync(path.join(cwd, 'package.json'));
delete require.cache[realPackage];
var pkg = require(realPackage);

Expand All @@ -20,13 +21,14 @@ module.exports.isEligable = function (path) {
return true;
};

module.exports.settings = function (path) {
var realPackage = fs.realpathSync(path + '/package.json');
module.exports.settings = function (cwd) {
var realPackage = fs.realpathSync(path.join(cwd, 'package.json'));
var pkg = require(realPackage);

var executableExtension = /^win/.test(process.platform) ? '.cmd' : '';
return {
name: pkg.engines.node ? 'npm' : 'apm',
exec: pkg.engines.node ? 'npm' : 'apm',
exec: (pkg.engines.node ? 'npm' : 'apm') + executableExtension,
args: [ '--color=always', 'install' ],
sh: false
};
Expand Down

0 comments on commit 55e4924

Please sign in to comment.