gulp-symlink
Advanced tools
Comparing version
26
index.js
@@ -13,2 +13,3 @@ /* jshint node:true */ | ||
File = gutil.File, | ||
isWin = process.platform === 'win32', | ||
debug; | ||
@@ -134,3 +135,2 @@ | ||
fs.stat(source.path, function(err, stat) { | ||
if(err) { | ||
@@ -143,6 +143,3 @@ return errored.call(self, err, callback); | ||
fs.symlink(source.resolved, symlink.path, source.stat.isDirectory() ? 'dir' : 'file', function(err) { | ||
if(err) { | ||
return errored.call(self, err, callback); | ||
} else { | ||
var success = function(){ | ||
if (options.log) { | ||
@@ -153,4 +150,23 @@ gutil.log(PLUGIN_NAME + ':' + gutil.colors.magenta(source.path), 'symlinked to', gutil.colors.magenta(symlink.path)); | ||
return callback(); | ||
}; | ||
if(err) { | ||
if (!isWin || err.code !== 'EPERM') { | ||
return errored.call(self, err, callback); | ||
} | ||
// Try with type "junction" on Windows | ||
// Junctions behave equally to true symlinks and can be created in | ||
// non elevated terminal (well, not always..) | ||
fs.symlink(source.resolved, symlink.path, 'junction', function(err) { | ||
if (err) { | ||
return errored.call(self, err, callback); | ||
} | ||
return success(); | ||
}); | ||
} | ||
return success(); | ||
}); | ||
@@ -157,0 +173,0 @@ |
{ | ||
"name": "gulp-symlink", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Create symlinks during your gulp build.", | ||
@@ -9,3 +9,3 @@ "license": "MIT", | ||
"name": "Ben Briggs", | ||
"email": "therealbenbriggs@hotmail.com", | ||
"email": "beneb.info@gmail.com", | ||
"url": "http://beneb.info" | ||
@@ -16,6 +16,3 @@ }, | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/ben-eb/gulp-symlink.git" | ||
}, | ||
"repository": "ben-eb/gulp-symlink", | ||
"keywords": [ | ||
@@ -26,18 +23,18 @@ "gulpplugin", | ||
"dependencies": { | ||
"gulp-util": "~3.0.0", | ||
"mkdirp": "~0.5.0", | ||
"through2": "~0.5.1", | ||
"async": "~0.9.0" | ||
"gulp-util": "~3.0.6", | ||
"mkdirp": "~0.5.1", | ||
"through2": "~2.0.0", | ||
"async": "~1.2.1" | ||
}, | ||
"devDependencies": { | ||
"chai": "~1.9.1", | ||
"chai": "~3.0.0", | ||
"clear": "0.0.1", | ||
"gulp-mocha": "~0.5.1", | ||
"jshint-stylish": "~0.1.5", | ||
"mocha": "~1.20.1", | ||
"gulp-jshint": "~1.7.1", | ||
"gulp": "~3.8.6", | ||
"rimraf": "~2.2.8" | ||
"gulp": "~3.9.0", | ||
"gulp-jshint": "~1.11.0", | ||
"gulp-mocha": "~2.1.2", | ||
"jshint-stylish": "~2.0.1", | ||
"mocha": "^2.2.5", | ||
"rimraf": "~2.4.0" | ||
}, | ||
"main": "index.js" | ||
} |
@@ -1,8 +0,8 @@ | ||
# [gulp](https://github.com/gulpjs/gulp)-symlink [](https://travis-ci.org/ben-eb/gulp-symlink) [](http://badge.fury.io/js/gulp-symlink) [](https://gemnasium.com/ben-eb/gulp-symlink) | ||
# [gulp](https://github.com/gulpjs/gulp)-symlink [](https://travis-ci.org/ben-eb/gulp-symlink) [](https://ci.appveyor.com/project/ben-eb/gulp-symlink/branch/master) [](https://gemnasium.com/ben-eb/gulp-symlink) | ||
> Create symlinks during your gulp build. | ||
## Installation | ||
## Install | ||
Install via [npm](https://npmjs.org/package/gulp-symlink): | ||
With [npm](https://npmjs.org/package/gulp-symlink) do: | ||
@@ -18,3 +18,3 @@ ``` | ||
gulp.task('default', function() { | ||
gulp.task('default', function () { | ||
return gulp.src('assets/some-large-video.mp4') | ||
@@ -35,5 +35,5 @@ .pipe(symlink('build/videos')) // Write to the destination folder | ||
```js | ||
gulp.task('symlink', function() { | ||
gulp.task('symlink', function () { | ||
return gulp.src('assets/some-large-video.mp4') | ||
.pipe(symlink(function(file) { | ||
.pipe(symlink(function (file) { | ||
// Here we return a path as string | ||
@@ -44,5 +44,5 @@ return path.join(file.base, 'build', file.relative.replace('some-large', '')); | ||
gulp.task('symlink-vinyl', function() { | ||
gulp.task('symlink-vinyl', function () { | ||
return gulp.src('assets/some-large-video.mp4') | ||
.pipe(symlink.absolute(function(file) { | ||
.pipe(symlink.absolute(function (file) { | ||
// Here we return a new Vinyl instance | ||
@@ -53,3 +53,3 @@ return new symlink.File({ | ||
}); | ||
}, { force: true })); | ||
}, {force: true})); | ||
}) | ||
@@ -64,4 +64,4 @@ ``` | ||
```js | ||
gulp.task('symlink-array', function() { | ||
return gulp.src('modules/assets/', 'modules/client/') | ||
gulp.task('symlink-array', function () { | ||
return gulp.src(['modules/assets/', 'modules/client/']) | ||
.pipe(symlink(['./assets', './client'])); | ||
@@ -76,1 +76,10 @@ }); | ||
The [vinyl module](https://github.com/wearefractal/vinyl) is exposed here. If you are creating new files with the function as shown above, please use this one. | ||
## Contributing | ||
Pull requests are welcome. If you add functionality, then please add unit tests | ||
to cover it. | ||
## License | ||
MIT © [Ben Briggs](http://beneb.info) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
19450
8.74%13
8.33%345
4.23%80
12.68%3
50%+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated