@parcel/fs-write-stream-atomic
Advanced tools
Comparing version 2.0.1-nightly.2520 to 2.0.1-nightly.2521
{ | ||
"name": "@parcel/fs-write-stream-atomic", | ||
"version": "2.0.1-nightly.2520+c8a64c9a", | ||
"version": "2.0.1-nightly.2521+e0440dcb", | ||
"description": "Like `fs.createWriteStream(...)`, but atomic.", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
"license": "ISC", | ||
"gitHead": "c8a64c9a533072c12681ca0805d1e4d7481ee53d" | ||
"gitHead": "e0440dcbe6d6e419a412c8c568d94715cdb4282a" | ||
} |
@@ -7,4 +7,4 @@ var fs = require('graceful-fs'); | ||
var rename = fs.rename; | ||
fs.rename = function(from, to, cb) { | ||
setTimeout(function() { | ||
fs.rename = function (from, to, cb) { | ||
setTimeout(function () { | ||
rename(from, to, cb); | ||
@@ -14,3 +14,3 @@ }, 100); | ||
test('basic', function(t) { | ||
test('basic', function (t) { | ||
// open 10 write streams to the same file. | ||
@@ -36,3 +36,3 @@ // then write to each of them, and to the target | ||
function verifier(ev, num) { | ||
return function() { | ||
return function () { | ||
if (ev === 'close') { | ||
@@ -48,3 +48,3 @@ t.equal(this.__emittedFinish, true, num + '. closed only after finish'); | ||
var lines = res.trim().split(/\n/); | ||
lines.forEach(function(line, lineno) { | ||
lines.forEach(function (line, lineno) { | ||
var first = lines[0].match(/\d+$/)[0]; | ||
@@ -55,3 +55,4 @@ var cur = line.match(/\d+$/)[0]; | ||
var resExpr = /^first write \d+\nsecond write \d+\nthird write \d+\nfinal write \d+\n$/; | ||
var resExpr = | ||
/^first write \d+\nsecond write \d+\nthird write \d+\nfinal write \d+\n$/; | ||
t.similar(res, resExpr, num + '. content matches'); | ||
@@ -62,3 +63,3 @@ }; | ||
// now write something to each stream. | ||
streams.forEach(function(stream, i) { | ||
streams.forEach(function (stream, i) { | ||
stream.write('first write ' + i + '\n'); | ||
@@ -68,3 +69,3 @@ }); | ||
// wait a sec for those writes to go out. | ||
setTimeout(function() { | ||
setTimeout(function () { | ||
// write something else to the target. | ||
@@ -74,7 +75,7 @@ fs.writeFileSync(target, 'brutality!\n'); | ||
// write some more stuff. | ||
streams.forEach(function(stream, i) { | ||
streams.forEach(function (stream, i) { | ||
stream.write('second write ' + i + '\n'); | ||
}); | ||
setTimeout(function() { | ||
setTimeout(function () { | ||
// Oops! Deleted the file! | ||
@@ -84,9 +85,9 @@ fs.unlinkSync(target); | ||
// write some more stuff. | ||
streams.forEach(function(stream, i) { | ||
streams.forEach(function (stream, i) { | ||
stream.write('third write ' + i + '\n'); | ||
}); | ||
setTimeout(function() { | ||
setTimeout(function () { | ||
fs.writeFileSync(target, 'brutality TWO!\n'); | ||
streams.forEach(function(stream, i) { | ||
streams.forEach(function (stream, i) { | ||
stream.end('final write ' + i + '\n'); | ||
@@ -99,8 +100,8 @@ }); | ||
test('cleanup', function(t) { | ||
test('cleanup', function (t) { | ||
fs.readdirSync(__dirname) | ||
.filter(function(f) { | ||
.filter(function (f) { | ||
return f.match(/^test.txt/); | ||
}) | ||
.forEach(function(file) { | ||
.forEach(function (file) { | ||
fs.unlinkSync(path.resolve(__dirname, file)); | ||
@@ -107,0 +108,0 @@ }); |
@@ -10,3 +10,3 @@ 'use strict'; | ||
test('chown works', function(t) { | ||
test('chown works', function (t) { | ||
t.plan(1); | ||
@@ -17,7 +17,7 @@ var stream = writeStream(target, { | ||
var hadError = false; | ||
stream.on('error', function(er) { | ||
stream.on('error', function (er) { | ||
hadError = true; | ||
console.log('#', er); | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.is(hadError, false, 'no errors before close'); | ||
@@ -28,5 +28,5 @@ }); | ||
test('chown fails', function(t) { | ||
test('chown fails', function (t) { | ||
t.plan(1); | ||
fs.chown = function(file, uid, gid, cb) { | ||
fs.chown = function (file, uid, gid, cb) { | ||
cb(new Error('TEST BREAK')); | ||
@@ -38,7 +38,7 @@ }; | ||
var hadError = false; | ||
stream.on('error', function(er) { | ||
stream.on('error', function (er) { | ||
hadError = true; | ||
console.log('#', er); | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.is(hadError, true, 'error before close'); | ||
@@ -49,5 +49,5 @@ }); | ||
test('cleanup', function(t) { | ||
test('cleanup', function (t) { | ||
rimraf.sync(target); | ||
t.end(); | ||
}); |
@@ -12,14 +12,14 @@ 'use strict'; | ||
test('rename eperm none existing file', function(t) { | ||
test('rename eperm none existing file', function (t) { | ||
t.plan(2); | ||
var _rename = fs.rename; | ||
fs.existsSync = function(src) { | ||
fs.existsSync = function (src) { | ||
return true; | ||
}; | ||
fs.rename = function(src, dest, cb) { | ||
fs.rename = function (src, dest, cb) { | ||
// simulate a failure during rename where the file | ||
// is renamed successfully but the process encounters | ||
// an EPERM error and the target file does not exist | ||
_rename(src, dest, function(e) { | ||
_rename(src, dest, function (e) { | ||
var err = new Error('TEST BREAK'); | ||
@@ -35,10 +35,10 @@ err.syscall = 'rename'; | ||
var calledFinish = false; | ||
stream.on('error', function(er) { | ||
stream.on('error', function (er) { | ||
hadError = true; | ||
console.log('#', er); | ||
}); | ||
stream.on('finish', function() { | ||
stream.on('finish', function () { | ||
calledFinish = true; | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.is(hadError, true, 'error was caught'); | ||
@@ -51,10 +51,10 @@ t.is(calledFinish, false, 'finish was called before close'); | ||
// test existing file with diff. content | ||
test('rename eperm existing file different content', function(t) { | ||
test('rename eperm existing file different content', function (t) { | ||
t.plan(2); | ||
var _rename = fs.rename; | ||
fs.existsSync = function(src) { | ||
fs.existsSync = function (src) { | ||
return true; | ||
}; | ||
fs.rename = function(src, dest, cb) { | ||
fs.rename = function (src, dest, cb) { | ||
// simulate a failure during rename where the file | ||
@@ -64,4 +64,4 @@ // is renamed successfully but the process encounters | ||
// destination | ||
_rename(src, dest, function(e) { | ||
fs.writeFile(src, 'dest', function(writeErr) { | ||
_rename(src, dest, function (e) { | ||
fs.writeFile(src, 'dest', function (writeErr) { | ||
if (writeErr) { | ||
@@ -71,3 +71,3 @@ return console.log('WRITEERR: ' + writeErr); | ||
fs.writeFile(target2, 'target', function(writeErr) { | ||
fs.writeFile(target2, 'target', function (writeErr) { | ||
if (writeErr) { | ||
@@ -89,10 +89,10 @@ return console.log('WRITEERR: ' + writeErr); | ||
var calledFinish = false; | ||
stream.on('error', function(er) { | ||
stream.on('error', function (er) { | ||
hadError = true; | ||
console.log('#', er); | ||
}); | ||
stream.on('finish', function() { | ||
stream.on('finish', function () { | ||
calledFinish = true; | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.is(hadError, true, 'error was caught'); | ||
@@ -106,10 +106,10 @@ t.is(calledFinish, false, 'finish was called before close'); | ||
// test existing file with diff. content | ||
test('rename eperm existing file different content', function(t) { | ||
test('rename eperm existing file different content', function (t) { | ||
t.plan(2); | ||
var _rename = fs.rename; | ||
fs.existsSync = function(src) { | ||
fs.existsSync = function (src) { | ||
return true; | ||
}; | ||
fs.rename = function(src, dest, cb) { | ||
fs.rename = function (src, dest, cb) { | ||
// simulate a failure during rename where the file | ||
@@ -119,4 +119,4 @@ // is renamed successfully but the process encounters | ||
// destination | ||
_rename(src, dest, function(e) { | ||
fs.writeFile(src, 'target2', function(writeErr) { | ||
_rename(src, dest, function (e) { | ||
fs.writeFile(src, 'target2', function (writeErr) { | ||
if (writeErr) { | ||
@@ -126,3 +126,3 @@ return console.log('WRITEERR: ' + writeErr); | ||
fs.writeFile(target3, 'target2', function(writeErr) { | ||
fs.writeFile(target3, 'target2', function (writeErr) { | ||
if (writeErr) { | ||
@@ -144,10 +144,10 @@ return console.log('WRITEERR: ' + writeErr); | ||
var calledFinish = false; | ||
stream.on('error', function(er) { | ||
stream.on('error', function (er) { | ||
hadError = true; | ||
console.log('#', er); | ||
}); | ||
stream.on('finish', function() { | ||
stream.on('finish', function () { | ||
calledFinish = true; | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.is(hadError, false, 'error was caught'); | ||
@@ -159,3 +159,3 @@ t.is(calledFinish, true, 'finish was called before close'); | ||
test('cleanup', function(t) { | ||
test('cleanup', function (t) { | ||
rimraf.sync(target); | ||
@@ -162,0 +162,0 @@ rimraf.sync(target2); |
@@ -10,5 +10,5 @@ 'use strict'; | ||
test('rename fails', function(t) { | ||
test('rename fails', function (t) { | ||
t.plan(1); | ||
fs.rename = function(src, dest, cb) { | ||
fs.rename = function (src, dest, cb) { | ||
cb(new Error('TEST BREAK')); | ||
@@ -18,7 +18,7 @@ }; | ||
var hadError = false; | ||
stream.on('error', function(er) { | ||
stream.on('error', function (er) { | ||
hadError = true; | ||
console.log('#', er); | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.is(hadError, true, 'error before close'); | ||
@@ -29,5 +29,5 @@ }); | ||
test('cleanup', function(t) { | ||
test('cleanup', function (t) { | ||
rimraf.sync(target); | ||
t.end(); | ||
}); |
@@ -10,3 +10,3 @@ 'use strict'; | ||
test('slow close', function(t) { | ||
test('slow close', function (t) { | ||
t.plan(2); | ||
@@ -21,6 +21,6 @@ // The goal here is to simulate the "file close" step happening so slowly | ||
var reallyClosed = false; | ||
fs.WriteStream.prototype.emit = function(event) { | ||
fs.WriteStream.prototype.emit = function (event) { | ||
if (event !== 'close') return realEmit.apply(this, arguments); | ||
setTimeout( | ||
function() { | ||
function () { | ||
reallyClosed = true; | ||
@@ -33,6 +33,6 @@ realEmit.call(this, 'close'); | ||
var stream = writeStream(target); | ||
stream.on('finish', function() { | ||
stream.on('finish', function () { | ||
t.is(reallyClosed, true, "didn't finish before target was closed"); | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.is(reallyClosed, true, "didn't close before target was closed"); | ||
@@ -43,5 +43,5 @@ }); | ||
test('cleanup', function(t) { | ||
test('cleanup', function (t) { | ||
rimraf.sync(target); | ||
t.end(); | ||
}); |
@@ -12,3 +12,3 @@ 'use strict'; | ||
test('the main process has thread -1', function(t) { | ||
test('the main process has thread -1', function (t) { | ||
t.equal(threadId, -1); | ||
@@ -19,3 +19,3 @@ t.end(); | ||
if (Worker != null) { | ||
test('workers have positive integer threadIds', function(t) { | ||
test('workers have positive integer threadIds', function (t) { | ||
t.plan(2); | ||
@@ -26,3 +26,3 @@ | ||
); | ||
w1.once('message', function(message) { | ||
w1.once('message', function (message) { | ||
t.equal(message, 1); | ||
@@ -33,3 +33,3 @@ }); | ||
); | ||
w2.once('message', function(message) { | ||
w2.once('message', function (message) { | ||
t.equal(message, 2); | ||
@@ -36,0 +36,0 @@ }); |
@@ -15,7 +15,7 @@ var path = require('path'); | ||
test('name too long', function(t) { | ||
test('name too long', function (t) { | ||
t.plan(2); | ||
var stream = writeStream(target); | ||
var hadError = false; | ||
stream.on('error', function(er) { | ||
stream.on('error', function (er) { | ||
if (!hadError) { | ||
@@ -30,3 +30,3 @@ t.is( | ||
}); | ||
stream.on('close', function() { | ||
stream.on('close', function () { | ||
t.ok(hadError, 'got error before close'); | ||
@@ -33,0 +33,0 @@ }); |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
20263
583