From 439260503481296ac8f3482ee901434fd7e3969e Mon Sep 17 00:00:00 2001 From: Jon Abrams Date: Thu, 25 Dec 2014 21:33:00 -0800 Subject: [PATCH 1/5] Add symlink support (Fixes #42) --- README.md | 16 +- index.js | 1 + lib/symlink/index.js | 61 ++++++++ test/symlink.js | 353 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 429 insertions(+), 2 deletions(-) create mode 100644 lib/symlink/index.js create mode 100644 test/symlink.js diff --git a/README.md b/README.md index c6de3e4a..dcc7ef29 100644 --- a/README.md +++ b/README.md @@ -72,12 +72,24 @@ This is just [glob-watcher] - mode - Specify the mode the files should be created with. Default is the mode of the input file (file.stat.mode) - Returns a Readable/Writable stream. - On write the stream will save the [vinyl] File to disk at the folder/cwd specified. -- After writing the file to disk, it will be emitted from the stream so you can keep piping these around -- The file will be modified after being written to this stream +- After writing the file to disk, it will be emitted from the stream so you can keep piping these around. +- The file will be modified after being written to this stream: - `cwd`, `base`, and `path` will be overwritten to match the folder - `stat.mode` will be overwritten if you used a mode parameter - `contents` will have it's position reset to the beginning if it is a stream +### symlink(folder[, opt]) + +- Takes a folder path as the first argument. +- First argument can also be a function that takes in a file and returns a folder path. +- Possible options for the second argument: + - cwd - Specify the working directory the folder is relative to. Default is `process.cwd()` +- Returns a Readable/Writable stream. +- On write the stream will create a symbolic link (i.e. symlink) on disk at the folder/cwd specified. +- After creating the symbolic link, it will be emitted from the stream so you can keep piping these around. +- The file will be modified after being written to this stream: + - `cwd`, `base`, and `path` will be overwritten to match the folder + [glob-stream]: https://github.com/wearefractal/glob-stream [node-glob]: https://github.com/isaacs/node-glob [gaze]: https://github.com/shama/gaze diff --git a/index.js b/index.js index 7306aa78..f05d2b80 100644 --- a/index.js +++ b/index.js @@ -3,5 +3,6 @@ module.exports = { src: require('./lib/src'), dest: require('./lib/dest'), + symlink: require('./lib/symlink'), watch: require('glob-watcher') }; diff --git a/lib/symlink/index.js b/lib/symlink/index.js new file mode 100644 index 00000000..c7666efa --- /dev/null +++ b/lib/symlink/index.js @@ -0,0 +1,61 @@ +'use strict'; + +var assign = require('object-assign'); +var path = require('path'); +var through2 = require('through2'); +var mkdirp = require('mkdirp'); +var fs = require('graceful-fs'); + +function symlink(outFolder, opt) { + opt = opt || {}; + if (typeof outFolder !== 'string' && typeof outFolder !== 'function') { + throw new Error('Invalid output folder'); + } + + var options = assign({ + cwd: process.cwd() + }, opt); + + var cwd = path.resolve(options.cwd); + + function linkFile (file, enc, cb) { + var basePath; + if (typeof outFolder === 'string') { + basePath = path.resolve(cwd, outFolder); + } + if (typeof outFolder === 'function') { + basePath = path.resolve(cwd, outFolder(file)); + } + var writePath = path.resolve(basePath, file.relative); + var writeFolder = path.dirname(writePath); + var srcPath = file.path; + + // wire up new properties + file.stat = file.stat ? file.stat : new fs.Stats(); + file.stat.mode = (options.mode || file.stat.mode); + file.cwd = cwd; + file.base = basePath; + file.path = writePath; + + // mkdirp the folder the file is going in + mkdirp(writeFolder, function(err){ + if (err) { + return cb(err); + } + fs.symlink(srcPath, writePath, function (err) { + if (err && err.code !== 'EEXIST') { + return cb(err); + } + + cb(null, file); + }); + }); + } + + var stream = through2.obj(linkFile); + // TODO: option for either backpressure or lossy + stream.resume(); + return stream; +} + +module.exports = symlink; diff --git a/test/symlink.js b/test/symlink.js new file mode 100644 index 00000000..9836f69f --- /dev/null +++ b/test/symlink.js @@ -0,0 +1,353 @@ +var spies = require('./spy'); +var chmodSpy = spies.chmodSpy; +var statSpy = spies.statSpy; + +var vfs = require('../'); + +var path = require('path'); +var fs = require('graceful-fs'); +var rimraf = require('rimraf'); + +var bufEqual = require('buffer-equal'); +var through = require('through2'); +var File = require('vinyl'); + +var should = require('should'); +require('mocha'); + +var wipeOut = function(cb) { + rimraf(path.join(__dirname, './out-fixtures/'), cb); + spies.setError('false'); + statSpy.reset(); + chmodSpy.reset(); +}; + +var dataWrap = function(fn) { + return function(data, enc, cb) { + fn(data); + cb(); + }; +}; + +var realMode = function(n) { + return n & 07777; +}; + +describe('symlink stream', function() { + beforeEach(wipeOut); + afterEach(wipeOut); + + it('should explode on invalid folder', function(done) { + var stream; + try { + stream = gulp.symlink(); + } catch (err) { + should.exist(err); + should.not.exist(stream); + done(); + } + }); + + it('should pass through writes with cwd', function(done) { + var inputPath = path.join(__dirname, './fixtures/test.coffee'); + + var expectedFile = new File({ + base: __dirname, + cwd: __dirname, + path: inputPath, + contents: null + }); + + var onEnd = function(){ + buffered.length.should.equal(1); + buffered[0].should.equal(expectedFile); + done(); + }; + + var stream = vfs.symlink('./out-fixtures/', {cwd: __dirname}); + + var buffered = []; + bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); + stream.pipe(bufferStream); + stream.write(expectedFile); + stream.end(); + }); + + it('should pass through writes with default cwd', function(done) { + var inputPath = path.join(__dirname, './fixtures/test.coffee'); + + var expectedFile = new File({ + base: __dirname, + cwd: __dirname, + path: inputPath, + contents: null + }); + + var onEnd = function(){ + buffered.length.should.equal(1); + buffered[0].should.equal(expectedFile); + done(); + }; + + var stream = vfs.symlink(path.join(__dirname, './out-fixtures/')); + + var buffered = []; + bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); + stream.pipe(bufferStream); + stream.write(expectedFile); + stream.end(); + }); + + it('should make link to the right folder with relative cwd', function(done) { + var inputPath = path.join(__dirname, './fixtures/test.coffee'); + var inputBase = path.join(__dirname, './fixtures/'); + var expectedPath = path.join(__dirname, './out-fixtures/test.coffee'); + var expectedCwd = __dirname; + var expectedBase = path.join(__dirname, './out-fixtures'); + var expectedContents = fs.readFileSync(inputPath); + + var expectedFile = new File({ + base: inputBase, + cwd: __dirname, + path: inputPath, + contents: expectedContents + }); + + var onEnd = function(){ + buffered.length.should.equal(1); + buffered[0].should.equal(expectedFile); + buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); + buffered[0].base.should.equal(expectedBase, 'base should have changed'); + buffered[0].path.should.equal(expectedPath, 'path should have changed'); + fs.existsSync(expectedPath).should.equal(true); + bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); + fs.readlinkSync(expectedPath).should.equal(inputPath); + done(); + }; + + var stream = vfs.symlink('./out-fixtures/', {cwd: path.relative(process.cwd(), __dirname)}); + + var buffered = []; + bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); + stream.pipe(bufferStream); + stream.write(expectedFile); + stream.end(); + }); + + it('should write buffer files to the right folder with function and relative cwd', function(done) { + var inputPath = path.join(__dirname, './fixtures/test.coffee'); + var inputBase = path.join(__dirname, './fixtures/'); + var expectedPath = path.join(__dirname, './out-fixtures/test.coffee'); + var expectedCwd = __dirname; + var expectedBase = path.join(__dirname, './out-fixtures'); + var expectedContents = fs.readFileSync(inputPath); + + var expectedFile = new File({ + base: inputBase, + cwd: __dirname, + path: inputPath, + contents: expectedContents + }); + + var onEnd = function(){ + buffered.length.should.equal(1); + buffered[0].should.equal(expectedFile); + buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); + buffered[0].base.should.equal(expectedBase, 'base should have changed'); + buffered[0].path.should.equal(expectedPath, 'path should have changed'); + fs.existsSync(expectedPath).should.equal(true); + bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); + fs.readlinkSync(expectedPath).should.equal(inputPath); + done(); + }; + + var stream = vfs.symlink(function(file){ + should.exist(file); + file.should.equal(expectedFile); + return './out-fixtures'; + }, {cwd: path.relative(process.cwd(), __dirname)}); + + var buffered = []; + bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); + stream.pipe(bufferStream); + stream.write(expectedFile); + stream.end(); + }); + + it('should write buffer files to the right folder', function(done) { + var inputPath = path.join(__dirname, './fixtures/test.coffee'); + var inputBase = path.join(__dirname, './fixtures/'); + var expectedPath = path.join(__dirname, './out-fixtures/test.coffee'); + var expectedContents = fs.readFileSync(inputPath); + var expectedCwd = __dirname; + var expectedBase = path.join(__dirname, './out-fixtures'); + var expectedMode = 0655; + + var expectedFile = new File({ + base: inputBase, + cwd: __dirname, + path: inputPath, + contents: expectedContents, + stat: { + mode: expectedMode + } + }); + + var onEnd = function(){ + buffered.length.should.equal(1); + buffered[0].should.equal(expectedFile); + buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); + buffered[0].base.should.equal(expectedBase, 'base should have changed'); + buffered[0].path.should.equal(expectedPath, 'path should have changed'); + fs.existsSync(expectedPath).should.equal(true); + bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); + fs.readlinkSync(expectedPath).should.equal(inputPath); + done(); + }; + + var stream = vfs.symlink('./out-fixtures/', {cwd: __dirname}); + + var buffered = []; + bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); + stream.pipe(bufferStream); + stream.write(expectedFile); + stream.end(); + }); + + it('should write streaming files to the right folder', function(done) { + var inputPath = path.join(__dirname, './fixtures/test.coffee'); + var inputBase = path.join(__dirname, './fixtures/'); + var expectedPath = path.join(__dirname, './out-fixtures/test.coffee'); + var expectedContents = fs.readFileSync(inputPath); + var expectedCwd = __dirname; + var expectedBase = path.join(__dirname, './out-fixtures'); + var expectedMode = 0655; + + var contentStream = through.obj(); + var expectedFile = new File({ + base: inputBase, + cwd: __dirname, + path: inputPath, + contents: contentStream, + stat: { + mode: expectedMode + } + }); + + var onEnd = function(){ + buffered.length.should.equal(1); + buffered[0].should.equal(expectedFile); + buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); + buffered[0].base.should.equal(expectedBase, 'base should have changed'); + buffered[0].path.should.equal(expectedPath, 'path should have changed'); + fs.existsSync(expectedPath).should.equal(true); + bufEqual(fs.readFileSync(expectedPath), expectedContents).should.equal(true); + fs.readlinkSync(expectedPath).should.equal(inputPath); + done(); + }; + + var stream = vfs.symlink('./out-fixtures/', {cwd: __dirname}); + + var buffered = []; + bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); + stream.pipe(bufferStream); + stream.write(expectedFile); + setTimeout(function(){ + contentStream.write(expectedContents); + contentStream.end(); + }, 100); + stream.end(); + }); + + it('should write directories to the right folder', function(done) { + var inputPath = path.join(__dirname, './fixtures/wow'); + var inputBase = path.join(__dirname, './fixtures/'); + var expectedPath = path.join(__dirname, './out-fixtures/wow'); + var expectedCwd = __dirname; + var expectedBase = path.join(__dirname, './out-fixtures'); + var expectedMode = 0655; + + var expectedFile = new File({ + base: inputBase, + cwd: __dirname, + path: inputPath, + contents: null, + stat: { + isDirectory: function(){ + return true; + }, + mode: expectedMode + } + }); + + var onEnd = function(){ + buffered.length.should.equal(1); + buffered[0].should.equal(expectedFile); + buffered[0].cwd.should.equal(__dirname, 'cwd should have changed'); + buffered[0].base.should.equal(expectedBase, 'base should have changed'); + buffered[0].path.should.equal(expectedPath, 'path should have changed'); + fs.readlinkSync(expectedPath).should.equal(inputPath); + fs.lstatSync(expectedPath).isDirectory().should.equal(false); + fs.statSync(expectedPath).isDirectory().should.equal(true); + done(); + }; + + var stream = vfs.symlink('./out-fixtures/', {cwd: __dirname}); + + var buffered = []; + bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); + stream.pipe(bufferStream); + stream.write(expectedFile); + stream.end(); + }); + + it('should report IO errors', function(done) { + var inputPath = path.join(__dirname, './fixtures/test.coffee'); + var inputBase = path.join(__dirname, './fixtures/'); + var expectedPath = path.join(__dirname, './out-fixtures/test.coffee'); + var expectedContents = fs.readFileSync(inputPath); + var expectedCwd = __dirname; + var expectedBase = path.join(__dirname, './out-fixtures'); + var expectedMode = 0722; + + var expectedFile = new File({ + base: inputBase, + cwd: __dirname, + path: inputPath, + contents: expectedContents, + stat: { + mode: expectedMode + } + }); + + fs.mkdirSync(expectedBase); + fs.chmodSync(expectedBase, 0); + + var stream = vfs.symlink('./out-fixtures/', {cwd: __dirname}); + stream.on('error', function(err) { + err.code.should.equal('EACCES'); + done(); + }); + stream.write(expectedFile); + }); + + ['end', 'finish'].forEach(function(eventName) { + it('should emit ' + eventName + ' event', function(done) { + var srcPath = path.join(__dirname, './fixtures/test.coffee'); + var stream = vfs.symlink('./out-fixtures/', {cwd: __dirname}); + + stream.on(eventName, function() { + done(); + }); + + var file = new File({ + path: srcPath, + cwd: __dirname, + contents: new Buffer("1234567890") + }); + + stream.write(file); + stream.end(); + }); + }); +}); From 15af3e58512c2cdfb00fcc6f8850cfffa69ef431 Mon Sep 17 00:00:00 2001 From: Jon Abrams Date: Sat, 27 Dec 2014 14:41:24 -0800 Subject: [PATCH 2/5] De-dup common code between dest + symlink (#42) --- lib/common/index.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ lib/dest/index.js | 40 +++------------------------------------- lib/symlink/index.js | 37 ++----------------------------------- 3 files changed, 49 insertions(+), 72 deletions(-) create mode 100644 lib/common/index.js diff --git a/lib/common/index.js b/lib/common/index.js new file mode 100644 index 00000000..145b5816 --- /dev/null +++ b/lib/common/index.js @@ -0,0 +1,44 @@ +var assign = require('object-assign'); +var path = require('path'); +var mkdirp = require('mkdirp'); +var fs = require('graceful-fs'); + +exports.prepDestAndResponse = function (outFolder, file, opt, cb) { + opt = opt || {}; + + var options = assign({ + cwd: process.cwd() + }, opt); + + var cwd = path.resolve(options.cwd); + + if (typeof outFolder !== 'string' && typeof outFolder !== 'function') { + throw new Error('Invalid output folder'); + } + + var basePath; + if (typeof outFolder === 'string') { + basePath = path.resolve(cwd, outFolder); + } + if (typeof outFolder === 'function') { + basePath = path.resolve(cwd, outFolder(file)); + } + + var writePath = path.resolve(basePath, file.relative); + var writeFolder = path.dirname(writePath); + + // wire up new properties + file.stat = file.stat ? file.stat : new fs.Stats(); + file.stat.mode = (options.mode || file.stat.mode); + file.cwd = cwd; + file.base = basePath; + file.path = writePath; + + // mkdirp the folder the file is going in + mkdirp(writeFolder, function(err){ + if (err) { + return cb(err); + } + cb(null, writePath); + }); +}; diff --git a/lib/dest/index.js b/lib/dest/index.js index 01434050..ae143528 100644 --- a/lib/dest/index.js +++ b/lib/dest/index.js @@ -1,53 +1,19 @@ 'use strict'; -var assign = require('object-assign'); -var path = require('path'); var through2 = require('through2'); -var mkdirp = require('mkdirp'); var fs = require('graceful-fs'); +var prepDestAndResponse = require('../common').prepDestAndResponse; var writeContents = require('./writeContents'); function dest(outFolder, opt) { - opt = opt || {}; - if (typeof outFolder !== 'string' && typeof outFolder !== 'function') { - throw new Error('Invalid output folder'); - } - - var options = assign({ - cwd: process.cwd() - }, opt); - - if (typeof options.mode === 'string') { - options.mode = parseInt(options.mode, 8); - } - - var cwd = path.resolve(options.cwd); - function saveFile (file, enc, cb) { - var basePath; - if (typeof outFolder === 'string') { - basePath = path.resolve(cwd, outFolder); - } - if (typeof outFolder === 'function') { - basePath = path.resolve(cwd, outFolder(file)); - } - var writePath = path.resolve(basePath, file.relative); - var writeFolder = path.dirname(writePath); - - // wire up new properties - file.stat = file.stat ? file.stat : new fs.Stats(); - file.stat.mode = (options.mode || file.stat.mode); - file.cwd = cwd; - file.base = basePath; - file.path = writePath; - - // mkdirp the folder the file is going in - mkdirp(writeFolder, function(err){ + prepDestAndResponse(outFolder, file, opt, function (err, writePath) { if (err) { return cb(err); } + writeContents(writePath, file, cb); }); } diff --git a/lib/symlink/index.js b/lib/symlink/index.js index c7666efa..46d71d28 100644 --- a/lib/symlink/index.js +++ b/lib/symlink/index.js @@ -1,47 +1,14 @@ 'use strict'; -var assign = require('object-assign'); -var path = require('path'); var through2 = require('through2'); -var mkdirp = require('mkdirp'); var fs = require('graceful-fs'); +var prepDestAndResponse = require('../common').prepDestAndResponse; function symlink(outFolder, opt) { - opt = opt || {}; - if (typeof outFolder !== 'string' && typeof outFolder !== 'function') { - throw new Error('Invalid output folder'); - } - - var options = assign({ - cwd: process.cwd() - }, opt); - - var cwd = path.resolve(options.cwd); - function linkFile (file, enc, cb) { - var basePath; - if (typeof outFolder === 'string') { - basePath = path.resolve(cwd, outFolder); - } - if (typeof outFolder === 'function') { - basePath = path.resolve(cwd, outFolder(file)); - } - var writePath = path.resolve(basePath, file.relative); - var writeFolder = path.dirname(writePath); var srcPath = file.path; - // wire up new properties - file.stat = file.stat ? file.stat : new fs.Stats(); - file.stat.mode = (options.mode || file.stat.mode); - file.cwd = cwd; - file.base = basePath; - file.path = writePath; - - // mkdirp the folder the file is going in - mkdirp(writeFolder, function(err){ - if (err) { - return cb(err); - } + prepDestAndResponse(outFolder, file, opt, function (err, writePath) { fs.symlink(srcPath, writePath, function (err) { if (err && err.code !== 'EEXIST') { return cb(err); From b447d5ea22bbd9a54bcdceccac8e94c0bd0e18e7 Mon Sep 17 00:00:00 2001 From: Jon Abrams Date: Sat, 27 Dec 2014 14:49:57 -0800 Subject: [PATCH 3/5] Fix jshint warnings --- lib/common/index.js | 2 ++ lib/dest/index.js | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/common/index.js b/lib/common/index.js index 145b5816..f200f4aa 100644 --- a/lib/common/index.js +++ b/lib/common/index.js @@ -1,3 +1,5 @@ +'use strict'; + var assign = require('object-assign'); var path = require('path'); var mkdirp = require('mkdirp'); diff --git a/lib/dest/index.js b/lib/dest/index.js index ae143528..da22923b 100644 --- a/lib/dest/index.js +++ b/lib/dest/index.js @@ -1,7 +1,6 @@ 'use strict'; var through2 = require('through2'); -var fs = require('graceful-fs'); var prepDestAndResponse = require('../common').prepDestAndResponse; var writeContents = require('./writeContents'); From 21d7528f04afbc88529a69e81e4c64823edbbfe9 Mon Sep 17 00:00:00 2001 From: Jon Abrams Date: Sat, 27 Dec 2014 16:48:49 -0800 Subject: [PATCH 4/5] Move and rename to prepareWrite.js --- lib/dest/index.js | 4 ++-- lib/{common/index.js => prepareWrite.js} | 2 +- lib/symlink/index.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename lib/{common/index.js => prepareWrite.js} (93%) diff --git a/lib/dest/index.js b/lib/dest/index.js index da22923b..32afbab8 100644 --- a/lib/dest/index.js +++ b/lib/dest/index.js @@ -1,14 +1,14 @@ 'use strict'; var through2 = require('through2'); -var prepDestAndResponse = require('../common').prepDestAndResponse; +var prewrite = require('../prepareWrite'); var writeContents = require('./writeContents'); function dest(outFolder, opt) { function saveFile (file, enc, cb) { - prepDestAndResponse(outFolder, file, opt, function (err, writePath) { + prewrite(outFolder, file, opt, function (err, writePath) { if (err) { return cb(err); } diff --git a/lib/common/index.js b/lib/prepareWrite.js similarity index 93% rename from lib/common/index.js rename to lib/prepareWrite.js index f200f4aa..be012e74 100644 --- a/lib/common/index.js +++ b/lib/prepareWrite.js @@ -5,7 +5,7 @@ var path = require('path'); var mkdirp = require('mkdirp'); var fs = require('graceful-fs'); -exports.prepDestAndResponse = function (outFolder, file, opt, cb) { +module.exports = function (outFolder, file, opt, cb) { opt = opt || {}; var options = assign({ diff --git a/lib/symlink/index.js b/lib/symlink/index.js index 46d71d28..73aed5a7 100644 --- a/lib/symlink/index.js +++ b/lib/symlink/index.js @@ -2,13 +2,13 @@ var through2 = require('through2'); var fs = require('graceful-fs'); -var prepDestAndResponse = require('../common').prepDestAndResponse; +var prewrite = require('../prepareWrite'); function symlink(outFolder, opt) { function linkFile (file, enc, cb) { var srcPath = file.path; - prepDestAndResponse(outFolder, file, opt, function (err, writePath) { + prewrite(outFolder, file, opt, function (err, writePath) { fs.symlink(srcPath, writePath, function (err) { if (err && err.code !== 'EEXIST') { return cb(err); From 587656487d7cd8a56cadd57d311d28af820377a0 Mon Sep 17 00:00:00 2001 From: Jon Abrams Date: Sat, 27 Dec 2014 16:54:43 -0800 Subject: [PATCH 5/5] Match function to prepareWrite.js filename --- lib/dest/index.js | 4 ++-- lib/symlink/index.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/dest/index.js b/lib/dest/index.js index 32afbab8..eb3da3d2 100644 --- a/lib/dest/index.js +++ b/lib/dest/index.js @@ -1,14 +1,14 @@ 'use strict'; var through2 = require('through2'); -var prewrite = require('../prepareWrite'); +var prepareWrite = require('../prepareWrite'); var writeContents = require('./writeContents'); function dest(outFolder, opt) { function saveFile (file, enc, cb) { - prewrite(outFolder, file, opt, function (err, writePath) { + prepareWrite(outFolder, file, opt, function (err, writePath) { if (err) { return cb(err); } diff --git a/lib/symlink/index.js b/lib/symlink/index.js index 73aed5a7..8f257417 100644 --- a/lib/symlink/index.js +++ b/lib/symlink/index.js @@ -2,13 +2,14 @@ var through2 = require('through2'); var fs = require('graceful-fs'); -var prewrite = require('../prepareWrite'); + +var prepareWrite = require('../prepareWrite'); function symlink(outFolder, opt) { function linkFile (file, enc, cb) { var srcPath = file.path; - prewrite(outFolder, file, opt, function (err, writePath) { + prepareWrite(outFolder, file, opt, function (err, writePath) { fs.symlink(srcPath, writePath, function (err) { if (err && err.code !== 'EEXIST') { return cb(err);