-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
24 changed files
with
518 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "gulp" | ||
"extends": "gulp", | ||
"rules": { | ||
"max-statements": [1, 40] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
var copyProps = require('copy-props'); | ||
|
||
var fromTo = { | ||
'flags.silent': 'silent', | ||
}; | ||
|
||
function mergeConfigToCliFlags(opt, config) { | ||
return copyProps(config, opt, fromTo); | ||
} | ||
|
||
module.exports = mergeConfigToCliFlags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var copyProps = require('copy-props'); | ||
|
||
var toFrom = { | ||
configPath: 'flags.gulpfile', | ||
configBase: 'flags.gulpfile', | ||
}; | ||
|
||
function mergeConfigToEnvFlags(env, config) { | ||
return copyProps(env, config, toFrom, convert, true); | ||
} | ||
|
||
function convert(value, configKey, envKey) { | ||
if (envKey === 'configBase') { | ||
return path.dirname(value); | ||
} | ||
return value; | ||
} | ||
|
||
module.exports = mergeConfigToEnvFlags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
var copyProps = require('copy-props'); | ||
var path = require('path'); | ||
|
||
function loadConfigFiles(configFiles, configFileOrder) { | ||
var config = {}; | ||
|
||
configFileOrder.forEach(loadFile); | ||
|
||
function loadFile(key) { | ||
var filePath = configFiles[key]; | ||
if (!filePath) { | ||
return; | ||
} | ||
|
||
copyProps(require(filePath), config, convert); | ||
|
||
function convert(value, name) { | ||
if (name === 'flags.gulpfile') { | ||
return path.resolve(path.dirname(filePath), value); | ||
} | ||
return value; | ||
} | ||
} | ||
|
||
return config; | ||
} | ||
|
||
module.exports = loadConfigFiles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
'use strict'; | ||
|
||
var expect = require('expect'); | ||
|
||
var path = require('path'); | ||
var fixturesDir = path.join(__dirname, 'fixtures/config'); | ||
|
||
var headLines = require('gulp-test-tools').headLines; | ||
var runner = require('gulp-test-tools').gulpRunner().basedir(fixturesDir); | ||
|
||
describe('config: flags.gulpfile', function() { | ||
|
||
it('Should configure with a .gulp.* file', function(done) { | ||
runner | ||
.chdir('flags/gulpfile') | ||
.gulp() | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
stdout = headLines(stdout, 2, 2); | ||
expect(stdout).toEqual( | ||
'This gulpfile : ' + | ||
path.join(fixturesDir, 'flags/gulpfile/is/here/mygulpfile.js') + | ||
'\n' + | ||
'The current directory : ' + path.join(fixturesDir, 'flags/gulpfile') | ||
); | ||
expect(stderr).toEqual(''); | ||
done(err); | ||
} | ||
}); | ||
|
||
it('Should configure with a .gulp.* file in the directory specified by ' + | ||
'\n\t--cwd', function(done) { | ||
runner | ||
.gulp('--cwd ./flags/gulpfile') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
stdout = headLines(stdout, 2, 3); | ||
expect(stdout).toEqual( | ||
'This gulpfile : ' + | ||
path.join(fixturesDir, 'flags/gulpfile/is/here/mygulpfile.js') + | ||
'\n' + | ||
'The current directory : ' + path.join(fixturesDir, 'flags/gulpfile') | ||
); | ||
expect(stderr).toEqual(''); | ||
done(err); | ||
} | ||
}); | ||
|
||
it('Should ignore a ./gulp.* file if another directory is specified by ' + | ||
'\n\t--cwd', function(done) { | ||
runner | ||
.chdir('./flags/gulpfile') | ||
.gulp('--cwd ./cwd') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
stdout = headLines(stdout, 1, 3); | ||
expect(stdout).toEqual( | ||
'Another gulpfile : ' + | ||
path.join(fixturesDir, 'flags/gulpfile/cwd/gulpfile.js') | ||
); | ||
expect(stderr).toEqual(''); | ||
done(err); | ||
} | ||
}); | ||
|
||
it('Should ignore a ./.gulp.* file if another gulpfile is specified by ' + | ||
'\n\t--gulpfile', function(done) { | ||
runner | ||
.chdir('./flags/gulpfile') | ||
.gulp('--gulpfile ./cwd/gulpfile.js') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
stdout = headLines(stdout, 1, 3); | ||
expect(stdout).toEqual( | ||
'Another gulpfile : ' + | ||
path.join(fixturesDir, 'flags/gulpfile/cwd/gulpfile.js') | ||
); | ||
expect(stderr).toEqual(''); | ||
done(err); | ||
} | ||
}); | ||
|
||
}); | ||
|
Oops, something went wrong.