+2
-2
@@ -1,2 +0,2 @@ | ||
| 'use strict'; | ||
| module.exports = require('./lib/fs'); | ||
| 'use strict' | ||
| module.exports = require('./lib/fs') |
+6
-6
@@ -1,7 +0,7 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var buffer = require('is-buffer'); | ||
| var vfile = require('vfile'); | ||
| var buffer = require('is-buffer') | ||
| var vfile = require('vfile') | ||
| module.exports = toVFile; | ||
| module.exports = toVFile | ||
@@ -14,6 +14,6 @@ /* Create a virtual file from a description. | ||
| if (typeof options === 'string' || buffer(options)) { | ||
| options = {path: String(options)}; | ||
| options = {path: String(options)} | ||
| } | ||
| return vfile(options); | ||
| return vfile(options) | ||
| } |
+34
-35
@@ -1,42 +0,41 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| var fs = require('fs'); | ||
| var func = require('x-is-function'); | ||
| var vfile = require('./core'); | ||
| var fs = require('fs') | ||
| var vfile = require('./core') | ||
| module.exports = vfile; | ||
| module.exports = vfile | ||
| vfile.read = read; | ||
| vfile.readSync = readSync; | ||
| vfile.write = write; | ||
| vfile.writeSync = writeSync; | ||
| vfile.read = read | ||
| vfile.readSync = readSync | ||
| vfile.write = write | ||
| vfile.writeSync = writeSync | ||
| /* Create a virtual file and read it in, asynchronously. */ | ||
| function read(description, options, callback) { | ||
| var file = vfile(description); | ||
| var file = vfile(description) | ||
| if (!callback && func(options)) { | ||
| callback = options; | ||
| options = null; | ||
| if (!callback && typeof options === 'function') { | ||
| callback = options | ||
| options = null | ||
| } | ||
| if (!callback) { | ||
| return new Promise(executor); | ||
| return new Promise(executor) | ||
| } | ||
| executor(null, callback); | ||
| executor(null, callback) | ||
| function executor(resolve, reject) { | ||
| fs.readFile(file.path, options, done); | ||
| fs.readFile(file.path, options, done) | ||
| function done(err, res) { | ||
| if (err) { | ||
| reject(err); | ||
| reject(err) | ||
| } else { | ||
| file.contents = res; | ||
| file.contents = res | ||
| if (resolve) { | ||
| resolve(file); | ||
| resolve(file) | ||
| } else { | ||
| callback(null, file); | ||
| callback(null, file) | ||
| } | ||
@@ -50,5 +49,5 @@ } | ||
| function readSync(description, options) { | ||
| var file = vfile(description); | ||
| file.contents = fs.readFileSync(file.path, options); | ||
| return file; | ||
| var file = vfile(description) | ||
| file.contents = fs.readFileSync(file.path, options) | ||
| return file | ||
| } | ||
@@ -58,26 +57,26 @@ | ||
| function write(description, options, callback) { | ||
| var file = vfile(description); | ||
| var file = vfile(description) | ||
| /* Weird, right? Otherwise `fs` doesn’t accept it. */ | ||
| if (!callback && func(options)) { | ||
| callback = options; | ||
| options = undefined; | ||
| if (!callback && typeof options === 'function') { | ||
| callback = options | ||
| options = undefined | ||
| } | ||
| if (!callback) { | ||
| return new Promise(executor); | ||
| return new Promise(executor) | ||
| } | ||
| executor(null, callback); | ||
| executor(null, callback) | ||
| function executor(resolve, reject) { | ||
| fs.writeFile(file.path, file.contents || '', options, done); | ||
| fs.writeFile(file.path, file.contents || '', options, done) | ||
| function done(err) { | ||
| if (err) { | ||
| reject(err); | ||
| reject(err) | ||
| } else if (resolve) { | ||
| resolve(); | ||
| resolve() | ||
| } else { | ||
| callback(); | ||
| callback() | ||
| } | ||
@@ -90,4 +89,4 @@ } | ||
| function writeSync(description, options) { | ||
| var file = vfile(description); | ||
| fs.writeFileSync(file.path, file.contents || '', options); | ||
| var file = vfile(description) | ||
| fs.writeFileSync(file.path, file.contents || '', options) | ||
| } |
+23
-13
| { | ||
| "name": "to-vfile", | ||
| "version": "2.2.0", | ||
| "version": "3.0.0", | ||
| "description": "Create a vfile from a file-path", | ||
@@ -28,24 +28,23 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "is-buffer": "^1.1.4", | ||
| "vfile": "^2.0.0", | ||
| "x-is-function": "^1.0.4" | ||
| "is-buffer": "^2.0.0", | ||
| "vfile": "^2.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "browserify": "^14.0.0", | ||
| "browserify": "^16.0.0", | ||
| "esmangle": "^1.0.1", | ||
| "nyc": "^11.0.0", | ||
| "remark-cli": "^4.0.0", | ||
| "remark-preset-wooorm": "^3.0.0", | ||
| "prettier": "^1.12.1", | ||
| "remark-cli": "^5.0.0", | ||
| "remark-preset-wooorm": "^4.0.0", | ||
| "tape": "^4.0.0", | ||
| "xo": "^0.18.0" | ||
| "xo": "^0.20.0" | ||
| }, | ||
| "scripts": { | ||
| "build-md": "remark . -qfo", | ||
| "format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
| "build-bundle": "browserify index.js --bare -s toVFile > to-vfile.js", | ||
| "build-mangle": "esmangle to-vfile.js > to-vfile.min.js", | ||
| "build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
| "lint": "xo", | ||
| "build": "npm run build-bundle && npm run build-mangle", | ||
| "test-api": "node test", | ||
| "test-coverage": "nyc --reporter lcov tape test.js", | ||
| "test": "npm run build && npm run lint && npm run test-coverage" | ||
| "test": "npm run format && npm run build && npm run test-coverage" | ||
| }, | ||
@@ -58,6 +57,17 @@ "nyc": { | ||
| }, | ||
| "prettier": { | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "singleQuote": true, | ||
| "bracketSpacing": false, | ||
| "semi": false, | ||
| "trailingComma": "none" | ||
| }, | ||
| "xo": { | ||
| "space": true, | ||
| "prettier": true, | ||
| "esnext": false, | ||
| "rules": { | ||
| "no-var": "off", | ||
| "prefer-arrow-callback": "off", | ||
| "object-shorthand": "off", | ||
| "unicorn/no-new-buffer": "off" | ||
@@ -64,0 +74,0 @@ }, |
+6
-6
@@ -19,7 +19,7 @@ # to-vfile [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
| ```js | ||
| var vfile = require('to-vfile'); | ||
| var vfile = require('to-vfile') | ||
| console.log(vfile('readme.md')); | ||
| console.log(vfile.readSync('.git/HEAD')); | ||
| console.log(vfile.readSync('.git/HEAD', 'utf8')); | ||
| console.log(vfile('readme.md')) | ||
| console.log(vfile.readSync('.git/HEAD')) | ||
| console.log(vfile.readSync('.git/HEAD', 'utf8')) | ||
| ``` | ||
@@ -86,3 +86,3 @@ | ||
| See [`contribute.md` in `vfile/vfile`][contribute] for ways to get started. | ||
| See [`contributing.md` in `vfile/vfile`][contributing] for ways to get started. | ||
@@ -116,4 +116,4 @@ This organisation has a [Code of Conduct][coc]. By interacting with this | ||
| [contribute]: https://github.com/vfile/vfile/blob/master/contributing.md | ||
| [contributing]: https://github.com/vfile/vfile/blob/master/contributing.md | ||
| [coc]: https://github.com/vfile/vfile/blob/master/code-of-conduct.md |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8707
2.56%2
-33.33%8
14.29%87
-1.14%+ Added
- Removed
- Removed
Updated