-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
21 changed files
with
225 additions
and
1 deletion.
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
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,109 @@ | ||
'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 eraseTime = require('gulp-test-tools').eraseTime; | ||
var runner = require('gulp-test-tools').gulpRunner().basedir(fixturesDir); | ||
|
||
describe('config: flags.require', function() { | ||
|
||
it('Should configure with an array in a .gulp.* file', function(done) { | ||
runner | ||
.chdir('flags/require/array') | ||
.gulp() | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
|
||
var requiring1 = eraseTime(headLines(stdout, 1)); | ||
expect(requiring1).toEqual('Requiring external module ./preload_one'); | ||
var requiring2 = eraseTime(headLines(stdout, 1, 1)); | ||
expect(requiring2).toEqual('Requiring external module ./preload_two'); | ||
var preload1 = eraseTime(headLines(stdout, 1, 4)); | ||
expect(preload1).toEqual('preload one!'); | ||
var preload2 = eraseTime(headLines(stdout, 1, 5)); | ||
expect(preload2).toEqual('preload two!'); | ||
done(err); | ||
} | ||
}); | ||
|
||
it('Should configure with a string in a .gulp.* file', function(done) { | ||
runner | ||
.chdir('flags/require/string') | ||
.gulp() | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
var requiring = eraseTime(headLines(stdout, 1)); | ||
expect(requiring).toEqual('Requiring external module ./preload'); | ||
var preload1 = eraseTime(headLines(stdout, 1, 3)); | ||
expect(preload1).toEqual('hello preload!'); | ||
done(err); | ||
} | ||
}); | ||
|
||
it('Combines --require flag with .gulp.* file flags.require', function(done) { | ||
runner | ||
.chdir('flags/require/join-flags') | ||
.gulp('--require ./preload_one') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
|
||
var requiring1 = eraseTime(headLines(stdout, 1)); | ||
expect(requiring1).toEqual('Requiring external module ./preload_one'); | ||
var requiring2 = eraseTime(headLines(stdout, 1, 1)); | ||
expect(requiring2).toEqual('Requiring external module ./preload_two'); | ||
var preload1 = eraseTime(headLines(stdout, 1, 4)); | ||
expect(preload1).toEqual('preload one!'); | ||
var preload2 = eraseTime(headLines(stdout, 1, 5)); | ||
expect(preload2).toEqual('preload two!'); | ||
done(err); | ||
} | ||
}); | ||
|
||
it('resolves relative requires against cwd', function(done) { | ||
runner | ||
.gulp('--cwd flags/require/with-cwd') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
var requiring = eraseTime(headLines(stdout, 1)); | ||
expect(requiring).toEqual('Requiring external module ../preload'); | ||
var preload1 = eraseTime(headLines(stdout, 1, 4)); | ||
expect(preload1).toEqual('hello preload!'); | ||
done(err); | ||
} | ||
}); | ||
|
||
it('works with absolute paths, ignoring cwd', function(done) { | ||
runner | ||
.gulp('--cwd flags/require/with-absolute') | ||
.run(cb); | ||
|
||
function cb(err, stdout, stderr) { | ||
expect(err).toEqual(null); | ||
expect(stderr).toEqual(''); | ||
|
||
var absolute = path.join(__dirname, './fixtures/config/flags/require/preload'); | ||
var requiring = eraseTime(headLines(stdout, 1)); | ||
expect(requiring).toEqual('Requiring external module ' + absolute); | ||
var preload1 = eraseTime(headLines(stdout, 1, 4)); | ||
expect(preload1).toEqual('hello preload!'); | ||
done(err); | ||
} | ||
}); | ||
}); | ||
|
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,8 @@ | ||
{ | ||
"flags": { | ||
"require": [ | ||
"./preload_one", | ||
"./preload_two" | ||
] | ||
} | ||
} |
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,9 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
gulp.task('default', function(done) { | ||
console.log(global.preload_one); | ||
console.log(global.preload_two); | ||
done(); | ||
}); |
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 @@ | ||
global.preload_one = 'preload one!'; |
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 @@ | ||
global.preload_two = 'preload two!'; |
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,7 @@ | ||
{ | ||
"flags": { | ||
"require": [ | ||
"./preload_two" | ||
] | ||
} | ||
} |
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,9 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
gulp.task('default', function(done) { | ||
console.log(global.preload_one); | ||
console.log(global.preload_two); | ||
done(); | ||
}); |
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 @@ | ||
global.preload_one = 'preload one!'; |
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 @@ | ||
global.preload_two = 'preload two!'; |
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 @@ | ||
global.preload = 'hello preload!'; |
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,5 @@ | ||
{ | ||
"flags": { | ||
"require": "./preload" | ||
} | ||
} |
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,8 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
gulp.task('default', function(done) { | ||
console.log(global.preload); | ||
done(); | ||
}); |
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 @@ | ||
global.preload = 'hello preload!'; |
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,7 @@ | ||
var path = require('path'); | ||
|
||
module.exports = { | ||
flags: { | ||
require: path.join(__dirname, '../preload'), | ||
}, | ||
}; |
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,8 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
gulp.task('default', function(done) { | ||
console.log(global.preload); | ||
done(); | ||
}); |
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,5 @@ | ||
{ | ||
"flags": { | ||
"require": "../preload" | ||
} | ||
} |
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,8 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
|
||
gulp.task('default', function(done) { | ||
console.log(global.preload); | ||
done(); | ||
}); |
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,4 @@ | ||
console.log('inside test module 2'); | ||
exports = function() { | ||
console.log('inside test module function 2'); | ||
}; |
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