Skip to content

Commit

Permalink
Breaking: Remove base option from dest/symlink options, use functio…
Browse files Browse the repository at this point in the history
…ns for folder instead (closes #141)
  • Loading branch information
phated committed Nov 30, 2017
1 parent 12f92f8 commit 7abaf4d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 110 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ Type: `String`

Default: `process.cwd()`

##### `options.base`

The folder relative to the cwd. This is used to determine the file names when saving in `.dest()`. Can also be a function that takes in a file and returns a folder path.

Type: `String` or `Function`

Default: The `cwd` resolved to the folder path.

##### `options.mode`

The mode the files should be created with.
Expand Down Expand Up @@ -254,14 +246,6 @@ Type: `String`

Default: `process.cwd()`

##### `options.base`

The folder relative to the cwd. This is used to determine the file names when saving in `.symlink()`. Can also be a function that takes in a file and returns a folder path.

Type: `String` or `Function`

Default: The `cwd` resolved to the folder path.

##### `options.dirMode`

The mode the directory should be created with.
Expand Down
3 changes: 1 addition & 2 deletions lib/prepare-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function prepareWrite(outFolder, file, opt, cb) {
var defaultMode = file.stat ? file.stat.mode : null;
var options = assign({}, opt, {
cwd: defaultValue(process.cwd(), string(opt.cwd, file)),
base: string(opt.base, file),
mode: defaultValue(defaultMode, number(opt.mode, file)),
dirMode: number(opt.dirMode, file),
overwrite: defaultValue(true, boolean(opt.overwrite, file)),
Expand All @@ -32,7 +31,7 @@ function prepareWrite(outFolder, file, opt, cb) {
if (!outFolderPath) {
throw new Error('Invalid output folder');
}
var basePath = options.base || path.resolve(cwd, outFolderPath);
var basePath = path.resolve(cwd, outFolderPath);
if (!basePath) {
throw new Error('Invalid base option');
}
Expand Down
62 changes: 0 additions & 62 deletions test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,68 +513,6 @@ describe('dest stream', function() {
stream.end();
});

it('should change to the specified base as string', function(done) {
var inputBase = path.join(__dirname, './fixtures');
var inputPath = path.join(__dirname, './fixtures/wow/suchempty');

var firstFile = new File({
cwd: __dirname,
path: inputPath,
stat: fs.statSync(inputPath),
});

var buffered = [];

var onEnd = function() {
buffered[0].base.should.equal(inputBase);
done();
};

var stream = vfs.dest('./out-fixtures/', {
cwd: __dirname,
base: inputBase,
});

var bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);

stream.pipe(bufferStream);
stream.write(firstFile);
stream.end();
});

it('should change to the specified base as function', function(done) {
var inputBase = path.join(__dirname, './fixtures');
var inputPath = path.join(__dirname, './fixtures/wow/suchempty');

var firstFile = new File({
cwd: __dirname,
path: inputPath,
stat: fs.statSync(inputPath),
});

var buffered = [];

var onEnd = function() {
buffered[0].base.should.equal(inputBase);
done();
};

var stream = vfs.dest('./out-fixtures/', {
cwd: __dirname,
base: function(file) {
should.exist(file);
file.path.should.equal(inputPath);
return inputBase;
},
});

var bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);

stream.pipe(bufferStream);
stream.write(firstFile);
stream.end();
});

it('should report IO errors', function(done) {
var inputPath = path.join(__dirname, './fixtures/test.coffee');
var inputBase = path.join(__dirname, './fixtures/');
Expand Down
30 changes: 0 additions & 30 deletions test/symlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,36 +351,6 @@ describe('symlink stream', function() {
stream.end();
});

it('should change to the specified base', function(done) {
var inputBase = path.join(__dirname, './fixtures');
var inputPath = path.join(__dirname, './fixtures/wow/suchempty');

var firstFile = new File({
base: inputBase,
cwd: __dirname,
path: inputPath,
stat: fs.statSync(inputPath),
});

var buffered = [];

var onEnd = function() {
buffered[0].base.should.equal(inputBase);
done();
};

var stream = vfs.symlink('./out-fixtures/', {
cwd: __dirname,
base: inputBase,
});

var bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);

stream.pipe(bufferStream);
stream.write(firstFile);
stream.end();
});

it('should report IO errors', function(done) {
if (isWindows) {
console.log('Changing the mode of a file is not supported by node.js in Windows.');
Expand Down

0 comments on commit 7abaf4d

Please sign in to comment.