gulp-symlink
Advanced tools
Comparing version
10
index.js
@@ -26,10 +26,12 @@ /* jshint node:true */ | ||
return cb(); | ||
} else if (typeof symlink === 'function') { | ||
symlink = symlink(file); | ||
} | ||
var destination = resolver.call(this, process.cwd(), symlink); | ||
var out = function(file) { | ||
return (typeof symlink === 'string') ? symlink : symlink(file); | ||
}; | ||
var destination = resolver.call(this, process.cwd(), out(file)); | ||
// Check whether the destination is a directory | ||
if (path.extname(symlink) === '') { | ||
if (path.extname(out(file)) === '') { | ||
sym = path.join(destination, path.basename(file.path)); | ||
@@ -36,0 +38,0 @@ } else { |
{ | ||
"name": "gulp-symlink", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Create symlinks during your gulp build.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
55
test.js
@@ -19,3 +19,3 @@ /* jshint node: true */ | ||
expect(fs.lstatSync(path).isSymbolicLink()).to.be.true; | ||
callback(); | ||
callback && callback(); | ||
}; | ||
@@ -28,8 +28,12 @@ | ||
beforeEach(function() { | ||
this.gutilFile = new gutil.File({ | ||
path: path.join(process.cwd(), testFile) | ||
}); | ||
}); | ||
it('should throw if no directory was specified', function(cb) { | ||
var stream = method(); | ||
try { | ||
stream.write(new gutil.File({ | ||
path: path.join(process.cwd(), testFile) | ||
})); | ||
stream.write(this.gutilFile); | ||
} catch (e) { | ||
@@ -47,5 +51,3 @@ expect(e.toString()).to.contain.string('An output destination is required.'); | ||
stream.write(new gutil.File({ | ||
path: path.join(process.cwd(), testFile) | ||
})); | ||
stream.write(this.gutilFile); | ||
}); | ||
@@ -64,5 +66,3 @@ it('should create symlinks renamed as a result of a function', function(cb) { | ||
stream.write(new gutil.File({ | ||
path: path.join(process.cwd(), testFile) | ||
})); | ||
stream.write(this.gutilFile); | ||
}); | ||
@@ -79,5 +79,3 @@ it('should create renamed symlinks', function(cb) { | ||
stream.write(new gutil.File({ | ||
path: path.join(process.cwd(), testFile) | ||
})); | ||
stream.write(this.gutilFile); | ||
}); | ||
@@ -94,6 +92,31 @@ it('should create symlinks in nested directories', function(cb) { | ||
stream.write(new gutil.File({ | ||
path: path.join(process.cwd(), testFile) | ||
})); | ||
stream.write(this.gutilFile); | ||
}); | ||
it('should symlink multiple input files in the same stream', function(cb) { | ||
var stream = method(function(file) { | ||
return path.join(testDir, file.relative); | ||
}); | ||
var fileOne = new gutil.File({ | ||
path: path.join(process.cwd(), 'test.js') | ||
}); | ||
var fileTwo = new gutil.File({ | ||
path: path.join(process.cwd(), 'README.md') | ||
}) | ||
stream.on('data', function(sym) { | ||
if (sym === fileOne) { | ||
assertion(path.join(testDir, 'test.js')); | ||
} else { | ||
assertion(path.join(testDir, 'README.md')); | ||
} | ||
}); | ||
stream.on('end', cb); | ||
stream.write(fileOne); | ||
stream.write(fileTwo); | ||
stream.end(); | ||
}); | ||
after(function(cb) { | ||
@@ -100,0 +123,0 @@ rimraf(testDir, cb); |
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
12352
5.96%1003
7.73%205
9.63%0
-100%