--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
75
node_modules/gulp-flatten/test/flatten-path.js
generated
vendored
Normal file
75
node_modules/gulp-flatten/test/flatten-path.js
generated
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
var should = require('should');
|
||||
var path = require('path');
|
||||
var flattenPath = require('../lib/flatten-path');
|
||||
var fileInstance;
|
||||
|
||||
describe('gulp-flatten', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
fileInstance = {
|
||||
base: '/some/project/src/',
|
||||
path: '/some/project/src/top1/top2/bottom2/bottom1/app.css',
|
||||
relative: 'top1/top2/bottom2/bottom1/app.css'
|
||||
};
|
||||
});
|
||||
|
||||
describe('includeParents', function () {
|
||||
it('should keep top parent dirs from indludeParents option', function (done) {
|
||||
var topOnly = flattenPath(fileInstance, {includeParents: 1});
|
||||
topOnly.should.equal('top1/app.css');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should keep bottom parent dirs from indludeParents option', function (done) {
|
||||
var bottomOnly = flattenPath(fileInstance, {includeParents: [0, 1]});
|
||||
bottomOnly.should.equal('bottom1/app.css');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should treat negative number in indludeParents as bottom parent levels', function (done) {
|
||||
var bottomOnly = flattenPath(fileInstance, {includeParents: -1});
|
||||
bottomOnly.should.equal('bottom1/app.css');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should keep top and bottom parent dirs from indludeParents option', function (done) {
|
||||
var both = flattenPath(fileInstance, {includeParents: [1, 2]});
|
||||
both.should.equal('top1/bottom2/bottom1/app.css');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should pick relative path if indludeParents bottom+top too long', function (done) {
|
||||
var relative = flattenPath(fileInstance, {includeParents: [10, 10]});
|
||||
relative.should.equal(fileInstance.relative);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('subPath', function () {
|
||||
it('should keep top parent dirs from subPath option', function (done) {
|
||||
var topOnly = flattenPath(fileInstance, {subPath: [0, 2]});
|
||||
topOnly.should.equal('top1/top2/app.css');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should keep bottom parent dirs from subPath option', function (done) {
|
||||
var bottomOnly = flattenPath(fileInstance, {subPath: -2});
|
||||
bottomOnly.should.equal('bottom2/bottom1/app.css');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should keep top2 and bottom2 from subPath option', function (done) {
|
||||
var middleOnly = flattenPath(fileInstance, {subPath: [1, -1]});
|
||||
middleOnly.should.equal('top2/bottom2/app.css');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
129
node_modules/gulp-flatten/test/main.js
generated
vendored
Normal file
129
node_modules/gulp-flatten/test/main.js
generated
vendored
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
var should = require('should');
|
||||
var flatten = require('../');
|
||||
var File = require('gulp-util').File;
|
||||
var gulp = require('gulp');
|
||||
var path = require('path');
|
||||
var fileInstance;
|
||||
|
||||
describe('gulp-flatten', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
fileInstance = new File({
|
||||
cwd: '/some/project/',
|
||||
base: '/some/project/src/',
|
||||
path: '/some/project/src/assets/css/app.css',
|
||||
contents: new Buffer('html { background-color: #777; }')
|
||||
});
|
||||
});
|
||||
|
||||
describe('flatten()', function () {
|
||||
it('should strip relative path without options', function (done) {
|
||||
var stream = flatten();
|
||||
stream.on('error', done);
|
||||
stream.on('data', function(newFile) {
|
||||
should.exist(newFile);
|
||||
should.exist(newFile.path);
|
||||
should.exist(newFile.relative);
|
||||
|
||||
newFile.relative.should.equal('app.css');
|
||||
done();
|
||||
});
|
||||
stream.write(fileInstance);
|
||||
});
|
||||
|
||||
it('should replace relative path with option path', function (done) {
|
||||
var stream = flatten({newPath: 'new/path'});
|
||||
stream.on('error', done);
|
||||
stream.on('data', function(newFile) {
|
||||
should.exist(newFile);
|
||||
should.exist(newFile.path);
|
||||
should.exist(newFile.relative);
|
||||
|
||||
newFile.relative.should.equal('new/path/app.css'.split('/').join(path.sep));
|
||||
done();
|
||||
});
|
||||
stream.write(fileInstance);
|
||||
});
|
||||
|
||||
it('should emit arg error with nonstring option', function (done) {
|
||||
var stream = flatten(123);
|
||||
stream.on('error', function (err) {
|
||||
should.exist(err);
|
||||
should.exist(err.message);
|
||||
should.ok(err.message === 'Path must be a string. Received undefined'
|
||||
|| err.message === 'Arguments to path.join must be strings')
|
||||
done();
|
||||
});
|
||||
stream.write(fileInstance);
|
||||
});
|
||||
|
||||
it('should ignore directories', function (done) {
|
||||
var stream = flatten();
|
||||
|
||||
stream.on('error', done);
|
||||
stream.on('data', function(newFile) {
|
||||
should.exist(newFile);
|
||||
should.exist(newFile.path);
|
||||
should.exist(newFile.relative);
|
||||
|
||||
newFile.relative.should.equal('test.css');
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('dottask', function () {
|
||||
gulp.src(path.join(__dirname, '/test_dir/**/*.css'))
|
||||
.pipe(stream);
|
||||
});
|
||||
|
||||
gulp.start('dottask');
|
||||
});
|
||||
|
||||
it('should strip relative path at the specified depth if depth option is passed', function (done) {
|
||||
var stream = flatten({includeParents: 2});
|
||||
stream.on('error', done);
|
||||
stream.on('data', function(newFile) {
|
||||
should.exist(newFile);
|
||||
should.exist(newFile.path);
|
||||
should.exist(newFile.relative);
|
||||
|
||||
newFile.relative.should.equal('one/two/app.css'.split('/').join(path.sep));
|
||||
done();
|
||||
});
|
||||
|
||||
fileInstance.path = '/some/project/src/one/two/three/four/app.css';
|
||||
stream.write(fileInstance);
|
||||
});
|
||||
|
||||
it('should leave path from the end if depth option is passed as negative number', function (done) {
|
||||
var stream = flatten({includeParents: -2});
|
||||
stream.on('error', done);
|
||||
stream.on('data', function(newFile) {
|
||||
should.exist(newFile);
|
||||
should.exist(newFile.path);
|
||||
should.exist(newFile.relative);
|
||||
|
||||
newFile.relative.should.equal('three/four/app.css'.split('/').join(path.sep));
|
||||
done();
|
||||
});
|
||||
|
||||
fileInstance.path = '/some/project/src/one/two/three/four/app.css';
|
||||
stream.write(fileInstance);
|
||||
});
|
||||
|
||||
it('should make no changes if the absolute depth option is greater than the tree depth', function (done) {
|
||||
var stream = flatten({includeParents: 8});
|
||||
stream.on('error', done);
|
||||
stream.on('data', function(newFile) {
|
||||
should.exist(newFile);
|
||||
should.exist(newFile.path);
|
||||
should.exist(newFile.relative);
|
||||
|
||||
newFile.relative.should.equal('one/two/three/four/app.css'.split('/').join(path.sep));
|
||||
done();
|
||||
});
|
||||
|
||||
fileInstance.path = '/some/project/src/one/two/three/four/app.css';
|
||||
stream.write(fileInstance);
|
||||
});
|
||||
});
|
||||
});
|
||||
3
node_modules/gulp-flatten/test/test_dir/some.css/test.css
generated
vendored
Normal file
3
node_modules/gulp-flatten/test/test_dir/some.css/test.css
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.myclass {
|
||||
color: red;
|
||||
}
|
||||
Loading…
Reference in a new issue