Gulp不会创建文件夹的链接

时间:2016-02-15 11:08:41

标签: gulp

无法通过 Gulp JS 创建指向 / var / www / project / bower_components / bootstrap / less / mixins 文件夹的符号链接。我试图通过nodeJS指定所需的路径。

VARIANT 1

CODE:

var gulp = require('gulp');
var path = require('path');
var debug = require('gulp-debug');
var symlink = require('gulp-sym');

gulp.task('symlink-deploy', function () {
    var mixins = gulp
        .src('' + path.resolve() + 'bower_components/bootstrap/less/mixins/')
        .pipe(symlink('' + path.resolve() + 'assets/less/'))
        .pipe(debug({title: 'unicorn:'}));

        return Promise.all([mixins]);
});
gulp.task('default', ['symlink-deploy']);

结果:

user@user-ThinkPad-Edge-E545:/var/www/project$ gulp symlink-deploy
[17:18:44] Using gulpfile /var/www/project/gulpfile.js
[17:18:44] Starting 'symlink-deploy'...
[17:18:44] Finished 'symlink-deploy' after 28 ms
events.js:141
  throw er; // Unhandled 'error' event
  ^

Error: EISDIR: illegal operation on a directory, read
at Error (native)
user@user-ThinkPad-Edge-E545:/var/www/project$

我也尝试过手动设置路径:

VARIANT 2

CODE:

var gulp = require('gulp');
var path = require('path');
var debug = require('gulp-debug');
var symlink = require('gulp-sym');

gulp.task('symlink-deploy', function () {
    var mixins = gulp
        .src('/home/user/www/project/bower_components/bootstrap/less/mixins')
        .pipe(symlink('/home/user/www/project/assets/less'))
        .pipe(debug({title: 'unicorn:'}));

        return Promise.all([mixins]);
});
gulp.task('default', ['symlink-deploy']);

结果:

user@user-ThinkPad-Edge-E545:/var/www/project$ gulp symlink-deploy
[17:57:55] Using gulpfile /var/www/project/gulpfile.js
[17:57:55] Starting 'symlink-deploy'...
[17:57:55] Finished 'symlink-deploy' after 27 ms

events.js:141
      throw er; // Unhandled 'error' event
      ^
Error: Destination file exists (/home/user/www/project/assets/less) - use force option to replace
    at Transform._transform (/var/www/project/node_modules/gulp-sym/index.js:55:26)
    at Transform._read (/var/www/project/node_modules/gulp-sym/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Transform._write (/var/www/project/node_modules/gulp-sym/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/var/www/project/node_modules/gulp-sym/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/var/www/project/node_modules/gulp-sym/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at Transform.Writable.write (/var/www/project/node_modules/gulp-sym/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at write (/var/www/project/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/var/www/project/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/var/www/project/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:664:5)
    at emitNone (events.js:67:13)
user@user-ThinkPad-Edge-E545:/var/www/project$

无法理解为什么它不起作用。请帮助!!!

0 个答案:

没有答案