Socket
Socket
Sign inDemoInstall

safefs

Package Overview
Dependencies
Maintainers
2
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safefs - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0-next.1573581968.f57353e1353147252e8c306eb5f06321631ea46a

.dependabot/config.yml

82

HISTORY.md
# History
## v4.2.0 2019 November 13
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)
## v4.1.0 2016 May 28
- Updated internal conventions
- Moved from [ESNextGuardian](https://github.com/bevry/esnextguardian) to [Editions](https://github.com/bevry/editions)
- Updated internal conventions
- Moved from [ESNextGuardian](https://github.com/bevry/esnextguardian) to [Editions](https://github.com/bevry/editions)
## v4.0.1 2015 December 10
- Updated internal conventions
- Updated internal conventions
## v4.0.0 2015 September 5
- Dropped node <0.12 support
- Dropped node <0.12 support
## v3.2.2 2015 September 5
- Use any version of `graceful-fs` to fix possible compat issues with node <0.10 support
- Use any version of `graceful-fs` to fix possible compat issues with node <0.10 support
## v3.2.1 2015 September 5
- Fixed node <0.10 support (regression since v3.2.0)
- Unfortunately our dev dependencies don't support this early, so no travis ci tests, manual tests pass
- Fixed node <0.10 support (regression since v3.2.0) - Unfortunately our dev dependencies don't support this early, so no travis ci tests, manual tests pass
## v3.2.0 2015 September 5
- Moved from CoffeeScript to ES6+
- Removed `cyclic.js` as it should no longer be needed
- Added tests... finally...
- Moved from CoffeeScript to ES6+
- Removed `cyclic.js` as it should no longer be needed
- Added tests... finally...
## v3.1.3 2015 March 18
- Updated dependencies
- Updated dependencies
## v3.1.2 2014 December 12
- Updated dependencies
- Updated dependencies
## v3.1.1 2014 February 5
- Safefs no longer fails to extend the safefs object with fs utilities under certain environments
- Thanks to [Merrick Christensen](https://github.com/iammerrick) and [Kyle Robinson Young](https://github.com/shama) for [issue #3](https://github.com/bevry/safefs/issues/3)
- Safefs no longer fails to extend the safefs object with fs utilities under certain environments - Thanks to [Merrick Christensen](https://github.com/iammerrick) and [Kyle Robinson Young](https://github.com/shama) for [issue #3](https://github.com/bevry/safefs/issues/3)
## v3.1.0 2013 December 9
- We no longer use our internal queue and now just rely on the graceful-fs queue
- We now alias all the other standard file system methods onto our own object
- We no longer use our internal queue and now just rely on the graceful-fs queue
- We now alias all the other standard file system methods onto our own object
## v3.0.6 2013 November 25
- Only unlink if the file exists
- Only unlink if the file exists
## v3.0.5 2013 November 17
- Use [graceful-fs](https://github.com/isaacs/node-graceful-fs) under the hood, along with our limiting abilities to help avoid even more problems
- Updated dependencies
- Use [graceful-fs](https://github.com/isaacs/node-graceful-fs) under the hood, along with our limiting abilities to help avoid even more problems
- Updated dependencies
## v3.0.4 2013 November 6
- Repackaged
- Updated dependencies
- Repackaged
- Updated dependencies
## v3.0.3 2013 August 29
- Added `lstat` functions
- Thanks to [James Gill](https://github.com/jagill) for [pull request #1](https://github.com/bevry/safefs/pull/1)
- Added `lstat` functions - Thanks to [James Gill](https://github.com/jagill) for [pull request #1](https://github.com/bevry/safefs/pull/1)
## v3.0.2 2013 August 29
- Updated dependencies
- Updated dependencies
## v3.0.1 2013 April 5
- Updated dependencies
- Updated dependencies
## v3.0.0 2013 April 5
- Rewrote to use [TaskGroup](https://npmjs.org/package/taskgroup) instead of the manual queue + setTimeout approach we were using before
- Rewrote to use [TaskGroup](https://npmjs.org/package/taskgroup) instead of the manual queue + setTimeout approach we were using before
## v2.0.3 2013 April 1
- Added missing `ensurePath` and `getParentPathSync`
- Added missing `ensurePath` and `getParentPathSync`
## v2.0.2 2013 April 1
- Added missing `ensurePath` and `getParentPathSync`
- Added missing `ensurePath` and `getParentPathSync`
## v2.0.1 2013 March 29
- Fixed readme code block
- Fixed readme code block
## v2.0.0 2013 March 29
- Split from [bal-util](https://github.com/balupton/bal-util)
- Split from [bal-util](https://github.com/balupton/bal-util)

@@ -1,3 +0,4 @@

// 2016 March 8
// https://github.com/bevry/editions
'use strict'
/** @type {typeof import("./source/index.js") } */
module.exports = require('editions').requirePackage(__dirname, require)

@@ -19,3 +19,3 @@ <!-- LICENSEFILE/ -->

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

@@ -22,0 +22,0 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

{
"title": "Safe FS",
"name": "safefs",
"version": "4.1.0",
"version": "4.2.0-next.1573581968.f57353e1353147252e8c306eb5f06321631ea46a",
"description": "Stop getting EMFILE errors! Open only as many files as the operating system supports.",

@@ -23,20 +23,27 @@ "homepage": "https://github.com/bevry/safefs",

"---",
"slackin",
"patreon",
"gratipay",
"flattr",
"liberapay",
"buymeacoffee",
"opencollective",
"crypto",
"paypal",
"bitcoin",
"wishlist"
],
"config": {
"buymeacoffeeUsername": "balupton",
"cryptoURL": "https://bevry.me/crypto",
"flattrUsername": "balupton",
"liberapayUsername": "bevry",
"opencollectiveUsername": "bevry",
"patreonUsername": "bevry",
"gratipayUsername": "bevry",
"flattrUsername": "balupton",
"paypalURL": "https://bevry.me/paypal",
"bitcoinURL": "https://bevry.me/bitcoin",
"wishlistURL": "https://bevry.me/wishlist",
"slackinURL": "https://slack.bevry.me"
"travisTLD": "com"
}
},
"funding": {
"type": "cooperative",
"url": "https://bevry.me/fund"
},
"author": "2013+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me), 2011-2012 Benjamin Lupton <b@lupton.cc> (http://balupton.com)",

@@ -48,6 +55,5 @@ "maintainers": [

"Benjamin Lupton <b@lupton.cc> (http://balupton.com)",
"James Gill (https://www.linkedin.com/in/jagill/)",
"James Gill (http://www.linkedin.com/in/jagill/)",
"Sean Fridman <mail@seanfridman.com> (http://seanfridman.com)",
"Kyle Robinson Young (http://dontkry.com)",
"Benjamin Lupton (https://balupton.com)"
"Kyle Robinson Young (http://dontkry.com)"
],

@@ -59,3 +65,3 @@ "bugs": {

"type": "git",
"url": "http://github.com/bevry/safefs.git"
"url": "https://github.com/bevry/safefs.git"
},

@@ -67,25 +73,27 @@ "engines": {

{
"description": "Source + ESNext + Require",
"entry": "source/index.js",
"description": "esnext source code with require for modules",
"directory": "source",
"syntaxes": [
"entry": "index.js",
"tags": [
"javascript",
"esnext",
"require",
"let",
"const",
"destructuring",
"defaults",
"template strings"
]
"require"
],
"engines": {
"node": "6 || 8 || 10 || 12 || 13",
"browsers": false
}
},
{
"description": "Babel Compiled + ES2015 + Require",
"entry": "es2015/index.js",
"directory": "es2015",
"syntaxes": [
"description": "esnext compiled for node.js 0.12 with require for modules",
"directory": "edition-node-0.12",
"entry": "index.js",
"tags": [
"javascript",
"es2015",
"require"
]
],
"engines": {
"node": "0.12 || 4 || 6 || 8 || 10 || 12 || 13",
"browsers": false
}
}

@@ -95,32 +103,74 @@ ],

"dependencies": {
"editions": "^1.1.1",
"graceful-fs": "^4.1.4"
"editions": "^2.2.0",
"graceful-fs": "^4.2.3"
},
"devDependencies": {
"assert-helpers": "^4.2.0",
"babel-cli": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"eslint": "^2.10.2",
"eslint-plugin-babel": "^3.2.0",
"joe": "^1.6.0",
"joe-reporter-console": "^1.2.1",
"projectz": "^1.1.5",
"rimraf": "^2.5.2"
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/preset-env": "^7.7.1",
"assert-helpers": "4.10.0",
"eslint": "^6.6.0",
"eslint-config-bevry": "^1.2.1",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-prettier": "^3.1.1",
"kava": "^3.1.0",
"prettier": "^1.19.1",
"projectz": "^1.9.0",
"rimraf": "2.7.1",
"valid-directory": "^1.0.0"
},
"scripts": {
"setup": "npm install",
"clean": "rm -Rf ./docs ./es2015",
"compile": "npm run compile:es2015",
"compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015",
"meta": "npm run meta:projectz",
"meta:projectz": "projectz compile",
"prepare": "npm run compile && npm run test && npm run meta",
"release": "npm run prepare && npm run release:publish && npm run release:tag && npm run release:push",
"release:publish": "npm publish",
"release:tag": "git tag v$npm_package_version -a",
"release:push": "git push origin master && git push origin --tags",
"pretest": "npm run test:eslint",
"test:eslint": "eslint ./source",
"test": "node --harmony -e \"require('editions').requirePackage(process.cwd(), require, 'test.js')\""
"our:clean": "rm -Rf ./docs ./edition* ./es2015 ./es5 ./out ./.next",
"our:compile": "npm run our:compile:edition-node-0.12",
"our:compile:edition-node-0.12": "env BABEL_ENV=edition-node-0.12 babel --out-dir ./edition-node-0.12 ./source",
"our:deploy": "echo no need for this project",
"our:meta": "npm run our:meta:projectz",
"our:meta:projectz": "projectz compile",
"our:release": "npm run our:release:prepare && npm run our:release:check-changelog && npm run our:release:check-dirty && npm run our:release:tag && npm run our:release:push",
"our:release:check-changelog": "cat ./HISTORY.md | grep v$npm_package_version || (echo add a changelog entry for v$npm_package_version && exit -1)",
"our:release:check-dirty": "git diff --exit-code",
"our:release:prepare": "npm run our:clean && npm run our:compile && npm run our:test && npm run our:meta",
"our:release:push": "git push origin master && git push origin --tags",
"our:release:tag": "export MESSAGE=$(cat ./HISTORY.md | sed -n \"/## v$npm_package_version/,/##/p\" | sed 's/## //' | awk 'NR>1{print buf}{buf = $0}') && test \"$MESSAGE\" || (echo 'proper changelog entry not found' && exit -1) && git tag v$npm_package_version -am \"$MESSAGE\"",
"our:setup": "npm run our:setup:install",
"our:setup:install": "npm install",
"our:test": "npm run our:verify && npm test",
"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:prettier",
"our:verify:directory": "npx valid-directory",
"our:verify:eslint": "eslint --fix --ignore-pattern '**/*.d.ts' --ignore-pattern '**/vendor/' --ignore-pattern '**/node_modules/' --ext .mjs,.js,.jsx,.ts,.tsx ./source",
"our:verify:prettier": "prettier --write ./source/**",
"test": "node ./test.js"
},
"eslintConfig": {
"extends": [
"bevry"
]
},
"prettier": {
"semi": false,
"singleQuote": true
},
"babel": {
"env": {
"edition-node-0.12": {
"sourceType": "script",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "0.12"
},
"modules": "commonjs"
}
]
],
"plugins": [
"@babel/proposal-object-rest-spread"
]
}
}
}
}

@@ -10,3 +10,3 @@ <!-- TITLE/ -->

<span class="badge-travisci"><a href="http://travis-ci.org/bevry/safefs" title="Check this project's build status on TravisCI"><img src="https://img.shields.io/travis/bevry/safefs/master.svg" alt="Travis CI Build Status" /></a></span>
<span class="badge-travisci"><a href="http://travis-ci.com/bevry/safefs" title="Check this project's build status on TravisCI"><img src="https://img.shields.io/travis/com/bevry/safefs/master.svg" alt="Travis CI Build Status" /></a></span>
<span class="badge-npmversion"><a href="https://npmjs.org/package/safefs" title="View this project on NPM"><img src="https://img.shields.io/npm/v/safefs.svg" alt="NPM version" /></a></span>

@@ -17,8 +17,9 @@ <span class="badge-npmdownloads"><a href="https://npmjs.org/package/safefs" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/safefs.svg" alt="NPM downloads" /></a></span>

<br class="badge-separator" />
<span class="badge-slackin"><a href="https://slack.bevry.me" title="Join this project's slack community"><img src="https://slack.bevry.me/badge.svg" alt="Slack community badge" /></a></span>
<span class="badge-patreon"><a href="http://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
<span class="badge-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin donate button" /></a></span>
<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span>

@@ -40,16 +41,16 @@

<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>NPM</h3></a><ul>
<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>npm</h3></a>
<ul>
<li>Install: <code>npm install --save safefs</code></li>
<li>Module: <code>require('safefs')</code></li></ul>
<li>Require: <code>require('safefs')</code></li>
</ul>
<h3><a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3>
<h3><a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3>
<p>This package is published with the following editions:</p>
<ul><li><code>safefs</code> aliases <code>safefs/index.js</code> which uses <a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li>
<li><code>safefs/source/index.js</code> is Source + <a href="https://babeljs.io/docs/learn-es2015/" title="ECMAScript Next">ESNext</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li>
<li><code>safefs/es2015/index.js</code> is <a href="https://babeljs.io" title="The compiler for writing next generation JavaScript">Babel</a> Compiled + <a href="http://babeljs.io/docs/plugins/preset-es2015/" title="ECMAScript 2015">ES2015</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li></ul>
<ul><li><code>safefs</code> aliases <code>safefs/index.js</code> which uses <a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li>
<li><code>safefs/source/index.js</code> is esnext source code with require for modules</li>
<li><code>safefs/edition-node-0.12/index.js</code> is esnext compiled for node.js 0.12 with require for modules</li></ul>
<p>Older environments may need <a href="https://babeljs.io/docs/usage/polyfill/" title="A polyfill that emulates missing ECMAScript environment features">Babel's Polyfill</a> or something similar.</p>
<!-- /INSTALL -->

@@ -105,3 +106,3 @@

<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/safefs/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/safefs">view contributions</a></li></ul>

@@ -112,7 +113,9 @@ <h3>Sponsors</h3>

<span class="badge-patreon"><a href="http://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
<span class="badge-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin donate button" /></a></span>
<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span>

@@ -124,7 +127,6 @@

<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li>
<li><a href="https://www.linkedin.com/in/jagill/">James Gill</a> — <a href="https://github.com/bevry/safefs/commits?author=jagill" title="View the GitHub contributions of James Gill on repository bevry/safefs">view contributions</a></li>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/safefs/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/safefs">view contributions</a></li>
<li><a href="http://www.linkedin.com/in/jagill/">James Gill</a> — <a href="https://github.com/bevry/safefs/commits?author=jagill" title="View the GitHub contributions of James Gill on repository bevry/safefs">view contributions</a></li>
<li><a href="http://seanfridman.com">Sean Fridman</a> — <a href="https://github.com/bevry/safefs/commits?author=sfrdmn" title="View the GitHub contributions of Sean Fridman on repository bevry/safefs">view contributions</a></li>
<li><a href="http://dontkry.com">Kyle Robinson Young</a> — <a href="https://github.com/bevry/safefs/commits?author=shama" title="View the GitHub contributions of Kyle Robinson Young on repository bevry/safefs">view contributions</a></li>
<li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/safefs/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/safefs">view contributions</a></li></ul>
<li><a href="http://dontkry.com">Kyle Robinson Young</a> — <a href="https://github.com/bevry/safefs/commits?author=shama" title="View the GitHub contributions of Kyle Robinson Young on repository bevry/safefs">view contributions</a></li></ul>

@@ -131,0 +133,0 @@ <a href="https://github.com/bevry/safefs/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>

/* eslint no-sync:0 */
'use strict'

@@ -7,3 +8,2 @@ // Import

// =====================================

@@ -13,3 +13,2 @@ // Define Module

const safefs = {
// =====================================

@@ -19,16 +18,17 @@ // Our own custom functions

// Get the parent path
getParentPathSync (path) {
return path
// remove trailing slashes
.replace(/[\/\\]$/, '')
// remove last directory
.replace(/[\/\\][^\/\\]+$/, '')
getParentPathSync(path) {
return (
path
// remove trailing slashes
.replace(/[/\\]$/, '')
// remove last directory
.replace(/[/\\][^/\\]+$/, '')
)
},
// Ensure path exists
// next(err, existed)
ensurePath (path, opts, next) {
ensurePath(path, opts, next) {
// Prepare
if ( next == null ) {
if (next == null) {
next = opts

@@ -40,19 +40,19 @@ opts = null

// Check
safefs.exists(path, function (exists) {
safefs.exists(path, function(exists) {
// Error
if ( exists ) return next(null, true)
if (exists) return next(null, true)
// Success
const parentPath = safefs.getParentPathSync(path)
safefs.ensurePath(parentPath, opts, function (err) {
safefs.ensurePath(parentPath, opts, function(err) {
// Error
if ( err ) return next(err, false)
if (err) return next(err, false)
// Success
safefs.mkdir(path, opts.mode, function () {
safefs.mkdir(path, opts.mode, function() {
// ignore mkdir error, as if it already exists, then we are winning
safefs.exists(path, function (exists) {
safefs.exists(path, function(exists) {
// Error
if ( !exists ) {
if (!exists) {
const err = new Error(`Failed to create the directory: ${path}`)

@@ -73,3 +73,2 @@ return next(err, false)

// =====================================

@@ -80,5 +79,5 @@ // Safe Wrappers for Standard Methods

// next(err)
writeFile (path, data, opts, next) {
writeFile(path, data, opts, next) {
// Prepare
if ( next == null ) {
if (next == null) {
next = opts

@@ -89,5 +88,5 @@ opts = null

// Ensure path
safefs.ensurePath(pathUtil.dirname(path), opts, function (err) {
safefs.ensurePath(pathUtil.dirname(path), opts, function(err) {
// Error
if ( err ) return next(err)
if (err) return next(err)

@@ -104,5 +103,5 @@ // Write data

// next(err)
appendFile (path, data, opts, next) {
appendFile(path, data, opts, next) {
// Prepare
if ( next == null ) {
if (next == null) {
next = opts

@@ -113,5 +112,5 @@ opts = null

// Ensure path
safefs.ensurePath(pathUtil.dirname(path), opts, function (err) {
safefs.ensurePath(pathUtil.dirname(path), opts, function(err) {
// Error
if ( err ) return next(err)
if (err) return next(err)

@@ -128,9 +127,9 @@ // Write data

// next(err)
mkdir (path, mode, next) {
mkdir(path, mode, next) {
// Prepare
if ( next == null ) {
if (next == null) {
next = mode
mode = null
}
if ( mode == null ) {
if (mode == null) {
/* eslint no-bitwise:0, no-magic-numbers:0 */

@@ -150,6 +149,6 @@ mode = 0o777 & ~process.umask()

// next(err)
unlink (path, next) {
unlink(path, next) {
// Stat
safefs.exists(path, function (exists) {
if ( exists === false ) return next()
safefs.exists(path, function(exists) {
if (exists === false) return next()
fsUtil.unlink(path, next)

@@ -164,3 +163,3 @@ })

// Add any missing methods
Object.keys(fsUtil).forEach(function (key) {
Object.keys(fsUtil).forEach(function(key) {
const value = fsUtil[key]

@@ -170,3 +169,3 @@ // we do the `!safefs[key]` as we don't want to over-write our own enhancements

// we do the `Function.prototype.bind` check, as underscore is a function that has it's own bind
if ( !safefs[key] && value && value.bind === Function.prototype.bind ) {
if (!safefs[key] && value && value.bind === Function.prototype.bind) {
safefs[key] = value.bind(fsUtil)

@@ -173,0 +172,0 @@ }

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