Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wrote

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wrote - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.nvmrc

16

.vscode/launch.json

@@ -19,3 +19,3 @@ {

"args": [
"test/spec/read-dir.js"
"es5/test/spec/erase.js"
],

@@ -25,4 +25,18 @@ "env": {

}
},
{
"type": "node",
"request": "launch",
"name": "Launch Zoroaster es5",
"program": "${workspaceRoot}/node_modules/.bin/zoroaster",
"runtimeExecutable": "${workspaceRoot}/node.sh",
"protocol": "legacy",
"args": [
"es5/test/spec/erase.js"
],
"env": {
"ZOROASTER_TIMEOUT": 9999999
}
}
]
}

@@ -0,1 +1,8 @@

## 29 December 2017
### 1.1.0
* [feature] `clone` with regular expressions transforms
* [feature] update `makePromise`
## 1.0.0 (28 Dec 2017)

@@ -2,0 +9,0 @@

6

es5/src/ensure-path.js
var fs = require('fs');
var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');

@@ -15,2 +15,4 @@ var _require = require('path'),

*/
function ensurePath(path) {

@@ -121,2 +123,2 @@ return new Promise(function ($return, $error) {

module.exports = ensurePath;
module.exports = ensurePath;

@@ -1,2 +0,2 @@

var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');
var fs = require('fs');

@@ -20,4 +20,4 @@

if (!ws.writable || ws.closed) {
return $error(new Error('stream should be writable'));
if (ws.closed) {
return $return();
}

@@ -24,0 +24,0 @@ promise = new Promise(function (resolve, reject) {

@@ -8,2 +8,3 @@ var ensurePath = require('./ensure-path');

var createWritable = require('./create-writable');
var clone = require('./clone');

@@ -17,3 +18,4 @@ module.exports = {

readDir,
readDirStructure
readDirStructure,
clone
};

@@ -6,3 +6,3 @@ var _require = require('path'),

var fs = require('fs');
var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');

@@ -9,0 +9,0 @@ /**

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var fs = require('fs');
var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');
var lib = require('./lib/');

@@ -6,0 +6,0 @@

var fs = require('fs');
var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');
var read = require('./read');

@@ -4,0 +4,0 @@

var Readable = require('stream').Readable;
var Writable = require('stream').Writable;
var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');

@@ -5,0 +5,0 @@ /**

var assert = require('assert');
var Catchment = require('catchment');
var fs = require('fs');
var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');

@@ -17,3 +17,5 @@ var _require = require('os'),

write = _require3.write,
erase = _require3.erase;
erase = _require3.erase,
readDir = _require3.readDir,
readDirStructure = _require3.readDirStructure;

@@ -129,2 +131,92 @@ var fixturesStructure = require('../fixtures/expected/read-dir-structure');

Object.defineProperties(this, {
readDir: {
value() {
var $args = arguments;return new Promise(function ($return, $error) {
var res;
return Promise.resolve(readDir.apply(undefined, $args)).then(function ($await_9) {
try {
res = $await_9;
return $return(res);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
}
},
readDirStructure: {
value() {
var $args = arguments;return new Promise(function ($return, $error) {
var res;
return Promise.resolve(readDirStructure.apply(undefined, $args)).then(function ($await_10) {
try {
res = $await_10;
return $return(res);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
}
},
readFixturesStructure: {
value() {
return new Promise(function ($return, $error) {
var res;
return Promise.resolve(readDirStructure(FIXTURES_TEST_DIR)).then(function ($await_11) {
try {
res = $await_11;
return $return(res);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
}
},
readTempStructure: {
value() {
return new Promise(function ($return, $error) {
var res;
return Promise.resolve(readDirStructure(TEMP_TEST_DIR)).then(function ($await_12) {
try {
res = $await_12;
return $return(res);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
}
},
readTemp: {
value() {
return new Promise(function ($return, $error) {
var res;
return Promise.resolve(readDir(TEMP_TEST_DIR, true)).then(function ($await_13) {
try {
res = $await_13;
return $return(res);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
}
},
readFixtures: {
value() {
return new Promise(function ($return, $error) {
var res;
return Promise.resolve(readDir(FIXTURES_TEST_DIR, true)).then(function ($await_14) {
try {
res = $await_14;
return $return(res);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
}
},
tempFile: {

@@ -145,7 +237,7 @@ get() {

tempFile = createTempFilePath();
return Promise.resolve(createWritable(tempFile)).then(function ($await_9) {
return Promise.resolve(createWritable(tempFile)).then(function ($await_15) {
try {
ws = $await_9;
ws = $await_15;
tempFileWs = ws;
return Promise.resolve(write(ws, this.TEST_DATA)).then(function ($await_10) {
return Promise.resolve(write(ws, this.TEST_DATA)).then(function ($await_16) {
try {

@@ -240,3 +332,3 @@ this._tempFile = tempFile;

}.bind(this);try {
return Promise.resolve(makePromise(fs.mkdir, [TEMP_NOX_DIR, 0o666])).then(function ($await_11) {
return Promise.resolve(makePromise(fs.mkdir, [TEMP_NOX_DIR, 0o666])).then(function ($await_17) {
try {

@@ -272,3 +364,3 @@ this._TEMP_NOX_DIR = TEMP_NOX_DIR;

// remove temp file
return Promise.resolve(Promise.all(promises)).then(function ($await_12) {
return Promise.resolve(Promise.all(promises)).then(function ($await_18) {
try {

@@ -302,5 +394,5 @@ return $return();

_spawnCommand = spawnCommand('rm', ['-rf', TEMP_TEST_DIR]), promise = _spawnCommand.promise;
return Promise.resolve(promise).then(function ($await_13) {
return Promise.resolve(promise).then(function ($await_19) {
try {
return Promise.resolve(makePromise(fs.mkdir, [TEMP_TEST_DIR, 0o777])).then(function ($await_14) {
return Promise.resolve(makePromise(fs.mkdir, [TEMP_TEST_DIR, 0o777])).then(function ($await_20) {
try {

@@ -307,0 +399,0 @@ this._TEMP_TEST_DIR = TEMP_TEST_DIR;

@@ -10,2 +10,3 @@ var assert = require('assert');

var createWritable = require('../../src/create-writable');
var clone = require('../../src/clone');
var api = require('../../src/');

@@ -38,2 +39,5 @@

assert.strictEqual(api.createWritable, createWritable);
},
'1.1.0 should export clone'() {
assert.strictEqual(api.clone, clone);
}

@@ -40,0 +44,0 @@ };

var assert = require('assert');
var makePromise = require('makepromise');
var makePromise = require('makepromise/es5/src/');
var erase = require('../../src/erase');

@@ -4,0 +4,0 @@ var createWritable = require('../../src/create-writable');

@@ -32,3 +32,3 @@ var _require = require('stream'),

assert.deepEqual(allData, [testString]);
assert(!ws.writable);
assert(ws._writableState.ended);
return $return();

@@ -59,3 +59,3 @@ } catch ($boundEx) {

assert.deepEqual(allData, [testString]);
assert(resWs._writableState.ended);
assert(ws._writableState.ended);
return $return();

@@ -208,3 +208,3 @@ } catch ($boundEx) {

assert.deepEqual(allData, []);
assert(!ws.writable);
assert(ws._writableState.ended);
return $return();

@@ -227,3 +227,3 @@ } catch ($boundEx) {

assert.deepEqual(allRawData, [buffer]);
assert(!ws.writable);
assert(ws._writableState.ended);
return $return();

@@ -230,0 +230,0 @@ } catch ($boundEx) {

{
"name": "wrote",
"version": "1.0.0",
"version": "1.1.0",
"description": "Promise-based writing to filesystem for Node.js",

@@ -40,8 +40,9 @@ "main": "src/index.js",

"spawncommand": "1.1.0",
"zoroaster": "0.4.4"
"zoroaster": "0.4.6"
},
"dependencies": {
"catchment": "1.0.0",
"makepromise": "1.0.0"
"makepromise": "1.1.1",
"restream": "1.2.0"
}
}

@@ -45,2 +45,33 @@ # wrote

## `wrote.clone({ from: string, to: string, regexes: [] }): Promise`
Clone a directory by copying contents of files and creating symlinks. Regular
expressions can be used to transform data being copied.
```js
const { clone } = require('wrote');
(async () => {
const from = './directory'
const to = './clone'
await clone({
from,
to,
regexes: [
{
re: /{{ name }}/g, // use /g flag for global replacements
replacement: 'Garry',
},
{
re: /{{ age }}/,
replacement: '30',
},
],
})
// or,
// await clone({ to, from })
})()
```
## `wrote.erase(ws: Writable): Promise.<Writable>`

@@ -47,0 +78,0 @@

@@ -9,4 +9,4 @@ const makePromise = require('makepromise')

async function endStream(ws) {
if (!ws.writable || ws.closed) {
throw new Error('stream should be writable')
if (ws.closed) {
return
}

@@ -13,0 +13,0 @@ const promise = new Promise((resolve, reject) => {

@@ -8,2 +8,3 @@ const ensurePath = require('./ensure-path')

const createWritable = require('./create-writable')
const clone = require('./clone')

@@ -18,2 +19,3 @@ module.exports = {

readDirStructure,
clone,
}

@@ -8,3 +8,5 @@ const assert = require('assert')

const spawnCommand = require('spawncommand')
const { createWritable, write, erase } = require('../../src/')
const {
createWritable, write, erase, readDir, readDirStructure,
} = require('../../src/')
const fixturesStructure = require('../fixtures/expected/read-dir-structure')

@@ -58,2 +60,38 @@

Object.defineProperties(this, {
readDir: {
async value(...args) {
const res = await readDir(...args)
return res
},
},
readDirStructure: {
async value(...args) {
const res = await readDirStructure(...args)
return res
},
},
readFixturesStructure: {
async value() {
const res = await readDirStructure(FIXTURES_TEST_DIR)
return res
},
},
readTempStructure: {
async value() {
const res = await readDirStructure(TEMP_TEST_DIR)
return res
},
},
readTemp: {
async value() {
const res = await readDir(TEMP_TEST_DIR, true)
return res
},
},
readFixtures: {
async value() {
const res = await readDir(FIXTURES_TEST_DIR, true)
return res
},
},
tempFile: {

@@ -60,0 +98,0 @@ get() {

@@ -10,2 +10,3 @@ const assert = require('assert')

const createWritable = require('../../src/create-writable')
const clone = require('../../src/clone')
const api = require('../../')

@@ -39,4 +40,7 @@

},
'1.1.0 should export clone'() {
assert.strictEqual(api.clone, clone)
},
}
module.exports = apiTestSuite

@@ -25,3 +25,3 @@ const { Readable, Writable } = require('stream')

assert.deepEqual(allData, [testString])
assert(!ws.writable)
assert(ws._writableState.ended)
},

@@ -40,3 +40,3 @@ async 'should pipe a readable to the stream'() {

assert.deepEqual(allData, [testString])
assert(resWs._writableState.ended)
assert(ws._writableState.ended)
},

@@ -98,3 +98,3 @@ async 'should reject when reabable is not readable'() {

assert.deepEqual(allData, [])
assert(!ws.writable)
assert(ws._writableState.ended)
},

@@ -107,3 +107,3 @@ async 'should write buffer'() {

assert.deepEqual(allRawData, [buffer])
assert(!ws.writable)
assert(ws._writableState.ended)
},

@@ -110,0 +110,0 @@ async 'should reject if writable is not Writable'() {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc