Comparing version 0.3.10 to 0.3.11
@@ -13,4 +13,2 @@ 'use strict'; | ||
// 511 = 0777 | ||
var processMode = 511 & (~process.umask()); | ||
@@ -31,3 +29,2 @@ function dest(outFolder, opt) { | ||
var cwd = path.resolve(options.cwd); | ||
var defaultMode = (options.mode || processMode); | ||
@@ -47,3 +44,3 @@ function saveFile (file, enc, cb) { | ||
file.stat = file.stat ? file.stat : new fs.Stats(); | ||
file.stat.mode = (options.mode || file.stat.mode || processMode); | ||
file.stat.mode = (options.mode || file.stat.mode); | ||
file.cwd = cwd; | ||
@@ -54,8 +51,7 @@ file.base = basePath; | ||
// mkdirp the folder the file is going in | ||
mkdirp(writeFolder, defaultMode, function(err){ | ||
mkdirp(writeFolder, function(err){ | ||
if (err) { | ||
cb(err); | ||
} else { | ||
writeContents(writePath, file, cb); | ||
return cb(err); | ||
} | ||
writeContents(writePath, file, cb); | ||
}); | ||
@@ -62,0 +58,0 @@ } |
{ | ||
"name": "vinyl-fs", | ||
"description": "Vinyl adapter for the file system", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"homepage": "http://github.com/wearefractal/vinyl-fs", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/wearefractal/vinyl-fs.git", |
@@ -373,2 +373,72 @@ var spies = require('./spy'); | ||
it('should write new files with the default user mode', 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 = 0666 & (~process.umask()); | ||
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); | ||
fs.existsSync(expectedPath).should.equal(true); | ||
realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); | ||
done(); | ||
}; | ||
chmodSpy.reset(); | ||
var stream = vfs.dest('./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 new files with the specified mode', 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 = 0744; | ||
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); | ||
fs.existsSync(expectedPath).should.equal(true); | ||
realMode(fs.lstatSync(expectedPath).mode).should.equal(expectedMode); | ||
done(); | ||
}; | ||
chmodSpy.reset(); | ||
var stream = vfs.dest('./out-fixtures/', {cwd: __dirname, mode:expectedMode}); | ||
var buffered = []; | ||
bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd); | ||
stream.pipe(bufferStream); | ||
stream.write(expectedFile); | ||
stream.end(); | ||
}); | ||
it('should update file mode to match the vinyl mode', function(done) { | ||
@@ -375,0 +445,0 @@ var inputPath = path.join(__dirname, './fixtures/test.coffee'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45001
1067