Skip to content

Commit

Permalink
add --gulpfile and --base. closes gulpjs#122
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Jan 13, 2014
1 parent a19dff7 commit 2db0075
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# gulp changelog

## 3.3.3

- support for `--base` CLI arg to change where the search for gulpfile/`--require`s starts
- support for `--gulpfile` CLI arg to point to a gulpfile specifically

## 3.3.0

- file.contents streams are no longer paused coming out of src
Expand Down
24 changes: 18 additions & 6 deletions bin/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@ var prettyTime = require('pretty-hrtime');
var tasks = argv._;
var cliPkg = require('../package.json');

var localBaseDir = process.cwd();
var localBaseDir;

if (argv.base) {
localBaseDir = path.resolve(argv.base);
} else {
localBaseDir = process.cwd();
}

loadRequires(argv.require, localBaseDir);

var gulpFile = getGulpFile(localBaseDir);
var gulpFile;

if (argv.gulpfile) {
gulpFile = path.resolve(argv.gulpfile);
} else {
gulpFile = getGulpFile(localBaseDir);
}

// find the local gulp
var localGulp = findLocalGulp(gulpFile);
Expand All @@ -39,20 +51,20 @@ if (argv.v || argv.version) {

if (!localGulp) {
gutil.log(gutil.colors.red('No local gulp install found in'), getLocalBase(gulpFile));
gutil.log(gutil.colors.red('Perhaps do: npm install gulp'));
gutil.log(gutil.colors.red('Try running: npm install gulp'));
process.exit(1);
}

// check for semver difference in running gulp vs locally installed and warn if running gulp > locally installed
if (semver.gt(cliPkg.version, localPkg.version)) {
gutil.log(gutil.colors.red('Gulp version mismatch:'));
gutil.log(gutil.colors.red('Running gulp is', cliPkg.version));
gutil.log(gutil.colors.red('gulp installed in gulpfile dir is', localPkg.version));
gutil.log(gutil.colors.red('Local gulp (installed in gulpfile dir) is', localPkg.version));
process.exit(1);
}

if (!gulpFile) {
gutil.log(gutil.colors.red('No Gulpfile found'));
gutil.log(gutil.colors.red('No gulpfile found'));
process.exit(1);
}

Expand Down Expand Up @@ -123,7 +135,7 @@ function getGulpFile(baseDir) {
} else {
extensions = ['.js'];
}
var gulpFile = findup('Gulpfile{'+extensions+'}', {nocase: true});
var gulpFile = findup('gulpfile{'+extensions+'}', {nocase: true});
return gulpFile;
}

Expand Down
17 changes: 9 additions & 8 deletions lib/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ var fs = require('fs');
var path = require('path');

module.exports = function(name) {
var file = path.join(__dirname, '../completion', name);
try {
console.log(fs.readFileSync(file, 'utf8'));
process.exit(0);
} catch (err) {
console.log('echo "Specified gulp shell auto-completion rules for \''+name+'\' not found"');
process.exit(5);
}
if (typeof name !== 'string') throw new Error('Missing completion type');
var file = path.join(__dirname, '../completion', name);
try {
console.log(fs.readFileSync(file, 'utf8'));
process.exit(0);
} catch (err) {
console.log('echo "Specified gulp shell auto-completion rules for \''+name+'\' not found"');
process.exit(5);
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gulp",
"description": "The streaming build system",
"version": "3.3.1",
"version": "3.3.2",
"homepage": "http://github.com/wearefractal/gulp",
"repository": "git://github.com/wearefractal/gulp.git",
"author": "Fractal <[email protected]> (http://wearefractal.com/)",
Expand Down
1 change: 0 additions & 1 deletion test/out-fixtures/copy/example.txt

This file was deleted.

0 comments on commit 2db0075

Please sign in to comment.