fix: pnpm list --long

This commit is contained in:
Zoltan Kochan
2020-06-22 01:40:24 +03:00
parent 220896511a
commit c776db1a7d
176 changed files with 161 additions and 3885 deletions

View File

@@ -0,0 +1,7 @@
---
"dependencies-hierarchy": major
"@pnpm/list": major
---
Look for dependencies at the correct location.
The dependency paths have changed in the `node_modules` created by pnpm v5.

View File

@@ -1,6 +1,6 @@
dependencies:
es6-iterator: 2.0.1
lockfileVersion: 5
lockfileVersion: 5.1
packages:
/d/1.0.0:
dependencies:

View File

@@ -4,7 +4,7 @@ importers:
is-positive: 1.0.0
specifiers:
is-positive: 1.0.0
lockfileVersion: 5
lockfileVersion: 5.1
packages:
/is-positive/1.0.0:
dev: false

View File

@@ -3,7 +3,7 @@ dependencies:
rimraf: 2.5.1
devDependencies:
is-positive: 1.0.0
lockfileVersion: 5
lockfileVersion: 5.1
optionalDependencies:
is-negative: 1.0.0
packages:

View File

@@ -3,7 +3,7 @@ dependencies:
rimraf: 2.5.1
devDependencies:
is-positive: 1.0.0
lockfileVersion: 5
lockfileVersion: 5.1
optionalDependencies:
is-negative: 1.0.0
packages:

View File

@@ -0,0 +1,17 @@
hoistPattern:
- '*'
hoistedDependencies: {}
included:
dependencies: true
devDependencies: true
optionalDependencies: true
layoutVersion: 4
packageManager: pnpm@0.0.0-2020520224551
pendingBuilds: []
publicHoistPattern:
- '@types/*'
registries:
default: 'https://registry.npmjs.org/'
skipped: []
storeDir: /home/zoli/.pnpm-store/v3
virtualStoreDir: .pnpm

View File

@@ -1,12 +1,14 @@
dependencies:
is-negative: 2.1.0
is-positive: 3.1.0
lockfileVersion: 5
lockfileVersion: 5.1
packages:
/is-negative/2.1.0:
dev: false
resolution:
integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=
/is-positive/3.1.0:
dev: false
resolution:
integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=
specifiers:

1
fixtures/has-not-outdated-deps/node_modules/is-negative generated vendored Symbolic link
View File

@@ -0,0 +1 @@
.pnpm/is-negative@2.1.0/node_modules/is-negative

1
fixtures/has-not-outdated-deps/node_modules/is-positive generated vendored Symbolic link
View File

@@ -0,0 +1 @@
.pnpm/is-positive@3.1.0/node_modules/is-positive

View File

@@ -1,12 +1,14 @@
dependencies:
is-negative: 2.1.0
is-positive: 3.1.0
lockfileVersion: 5
lockfileVersion: 5.1
packages:
/is-negative/2.1.0:
dev: false
resolution:
integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=
/is-positive/3.1.0:
dev: false
resolution:
integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=
specifiers:

5
fixtures/package.yaml Normal file
View File

@@ -0,0 +1,5 @@
scripts:
prepareFixtures: >
pnpm install -rf --frozen-lockfile --no-shared-workspace-lockfile --no-link-workspace-packages &&
pnpm install -rf -C fixtureWithLinks --frozen-lockfile --link-workspace-packages --no-shared-workspace-lockfile &&
cd ./fixture-with-external-shrinkwrap/pkg && pnpm install -f --frozen-lockfile

View File

@@ -1 +1,9 @@
# This file is only created so that tests don't look up the pnpm-workspace.yaml in the root
packages:
- '*'
- '!fixtureWithLinks/*'
- '!has-major-outdated-deps'
- '!has-no-lockfile'
- '!has-npm-shrinkwrap-json'
- '!has-package-lock-json'
- '!hello-world-js-bin'
- '!has-outdated-deps'

View File

@@ -1,7 +1,7 @@
dependencies:
general: 'link:../general'
is-positive: 3.1.0
lockfileVersion: 5
lockfileVersion: 5.1
packages:
/is-positive/3.1.0:
dev: false

View File

@@ -0,0 +1,2 @@
shamefully-hoist=false
public-hoist-pattern[]=

View File

@@ -1,6 +1,6 @@
dependencies:
symlink-dir: 2.0.2
lockfileVersion: 5
lockfileVersion: 5.1
packages:
/@types/mz/0.0.32:
dependencies:

View File

@@ -2,7 +2,7 @@
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"prepare": "pnpm install --dir verdaccio",
"prepare": "pnpm install --dir verdaccio && pnpm run prepareFixtures -C fixtures",
"lint": "tslint --config tslint.json **/src/**/*.ts **/test/**/*.ts --exclude '**/node_modules/**'",
"test-master": "pnpm run lint && pnpm run compile && run-p -r verdaccio test-pkgs-master",
"test-pkgs-master": "cross-env PNPM_REGISTRY_MOCK_UPLINK=http://localhost:7348 pnpm run _test --no-sort --filter=./packages --filter=./privatePackages --workspace-concurrency=2",

View File

@@ -1 +0,0 @@
!node_modules

View File

@@ -1,15 +0,0 @@
importers:
package:
hoistedAliases: {}
shamefullyFlatten: false
included:
dependencies: true
devDependencies: true
optionalDependencies: true
layoutVersion: 1
packageManager: pnpm@2.25.5
pendingBuilds: []
registries:
default: 'https://registry.npmjs.org/'
skipped: []
store: /home/zoltan/.pnpm-store/2

View File

@@ -1,14 +0,0 @@
importers:
foobarpackage:
dependencies:
is-positive: 3.1.0
specifiers:
is-positive: 3.1.0
packages:
/is-positive/3.1.0:
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=
shrinkwrapVersion: 4

View File

@@ -1,3 +0,0 @@
shamefully-hoist=false
shared-workspace-lockfile=false
link-workspace-packages=false

View File

@@ -1,6 +0,0 @@
!node_modules
node_modules/.bin
node_modules/.pnpm
node_modules/general
node_modules/symlink-dir
node_modules/.modules.yaml

View File

@@ -1,4 +0,0 @@
'use strict';
module.exports = function (n) {
return toString.call(n) === '[object Number]' && n > 0;
};

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Kevin Martensson <kevinmartensson@gmail.com> (github.com/kevva)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.

View File

@@ -1,63 +0,0 @@
{
"_from": "is-positive@3.1.0",
"_id": "is-positive@3.1.0",
"_inBundle": false,
"_integrity": "sha1-hX21hKG6XRyymAUn/DtsQ103sP0=",
"_location": "/is-positive",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "is-positive@3.1.0",
"name": "is-positive",
"escapedName": "is-positive",
"rawSpec": "3.1.0",
"saveSpec": null,
"fetchSpec": "3.1.0"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/is-positive/-/is-positive-3.1.0.tgz",
"_shasum": "857db584a1ba5d1cb2980527fc3b6c435d37b0fd",
"_spec": "is-positive@3.1.0",
"_where": "C:\\Users\\zoltan\\src\\pnpm\\pnpm\\packages\\dependencies-hierarchy\\fixtures\\with-undeclared-deps",
"author": {
"name": "Kevin Martensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/is-positive/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Check if something is a positive number",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/is-positive#readme",
"keywords": [
"number",
"positive",
"test",
"check"
],
"license": "MIT",
"name": "is-positive",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/is-positive.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "3.1.0"
}

View File

@@ -1,44 +0,0 @@
# is-positive [![Build Status](https://travis-ci.org/kevva/is-positive.svg?branch=master)](https://travis-ci.org/kevva/is-positive)
> Check if something is a positive number
## Install
```
$ npm install --save is-positive
```
## Usage
```js
const isPositive = require('is-positive');
isPositive(1);
//=> true
isPositive(0);
//=> false
isPositive(-1);
//=> false
isPositive('1');
//=> false
isPositive(Number(1))
//=> true
```
_Note: This module doesn't consider `0` to be a positive number and doesn't distinguish between `-0` and `0`. If you want to detect `0`, use the [`positive-zero`](https://github.com/sindresorhus/positive-zero) module._
## Related
- [is-negative](https://github.com/kevva/is-negative) - Check if something is a negative number
## License
MIT © [Kevin Martensson](http://github.com/kevva)

View File

@@ -10,7 +10,6 @@
],
"scripts": {
"lint": "tslint -c ../../tslint.json src/**/*.ts test/**/*.ts",
"pre_test": "pnpm install -rf -C fixtures --frozen-lockfile --no-shared-workspace-lockfile --no-link-workspace-packages && pnpm install -rf -C fixtureWithLinks --frozen-lockfile --link-workspace-packages --no-shared-workspace-lockfile",
"_test": "cd ../.. && c8 --reporter lcov --reports-dir packages/dependencies-hierarchy/coverage ts-node packages/dependencies-hierarchy/test --type-check",
"test": "pnpm run compile && pnpm run _test",
"prepublishOnly": "pnpm run compile",
@@ -37,6 +36,7 @@
"@pnpm/lockfile-utils": "workspace:2.0.14",
"@pnpm/modules-yaml": "workspace:8.0.0",
"@pnpm/normalize-registries": "workspace:1.0.2",
"@pnpm/pkgid-to-filename": "^3.0.0",
"@pnpm/read-modules-dir": "workspace:2.0.1",
"@pnpm/read-package-json": "workspace:3.1.2",
"@pnpm/types": "workspace:6.1.0",

View File

@@ -13,10 +13,11 @@ import {
} from '@pnpm/lockfile-utils'
import { read as readModulesYaml } from '@pnpm/modules-yaml'
import normalizeRegistries from '@pnpm/normalize-registries'
import pkgIdToFilename from '@pnpm/pkgid-to-filename'
import readModulesDir from '@pnpm/read-modules-dir'
import { safeReadPackageFromDir } from '@pnpm/read-package-json'
import { DependenciesField, DEPENDENCIES_FIELDS, Registries } from '@pnpm/types'
import { refToAbsolute, refToRelative } from 'dependency-path'
import { refToRelative } from 'dependency-path'
import normalizePath = require('normalize-path')
import path = require('path')
import realpathMissing = require('realpath-missing')
@@ -129,6 +130,7 @@ async function dependenciesHierarchyForPackage (
currentDepth: 1,
currentPackages: currentLockfile.packages || {},
includeOptionalDependencies: opts.include.optionalDependencies === true,
lockfileDir: opts.lockfileDir,
maxDepth: opts.depth,
modulesDir,
registries: opts.registries,
@@ -144,6 +146,7 @@ async function dependenciesHierarchyForPackage (
const { packageInfo, packageAbsolutePath } = getPkgInfo({
alias,
currentPackages: currentLockfile.packages || {},
lockfileDir: opts.lockfileDir,
modulesDir,
ref: topDeps[alias],
registries: opts.registries,
@@ -224,6 +227,7 @@ function getAllDirectDependencies (projectSnapshot: ProjectSnapshot) {
type GetTreeOpts = {
currentDepth: number,
maxDepth: number,
lockfileDir: string,
modulesDir: string,
includeOptionalDependencies: boolean,
search?: SearchFunction,
@@ -274,6 +278,7 @@ function getTreeHelper (
const { packageInfo, packageAbsolutePath } = getPkgInfo({
alias,
currentPackages: opts.currentPackages,
lockfileDir: opts.lockfileDir,
modulesDir: opts.modulesDir,
peers,
ref: deps[alias],
@@ -337,6 +342,7 @@ function getTreeHelper (
function getPkgInfo (
opts: {
alias: string,
lockfileDir: string,
modulesDir: string,
ref: string,
currentPackages: PackageSnapshots,
@@ -381,14 +387,14 @@ function getPkgInfo (
name = opts.alias
version = opts.ref
}
const packageAbsolutePath = refToAbsolute(opts.ref, opts.alias, opts.registries)
const packageAbsolutePath = refToRelative(opts.ref, opts.alias)
const packageInfo = {
alias: opts.alias,
isMissing,
isPeer: Boolean(opts.peers && opts.peers.has(opts.alias)),
isSkipped,
name,
path: packageAbsolutePath && path.join(opts.modulesDir, '.pnpm', packageAbsolutePath) || path.join(opts.modulesDir, '..', opts.ref.substr(5)),
path: depPath ? path.join(opts.modulesDir, '.pnpm', pkgIdToFilename(depPath, opts.lockfileDir)) : path.join(opts.modulesDir, '..', opts.ref.substr(5)),
version,
}
if (resolved) {

View File

@@ -1,7 +1,7 @@
{
"dependencies": [
{
"path": "registry.npmjs.org/es6-iterator/2.0.1",
"path": "es6-iterator@2.0.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -11,7 +11,7 @@
"version": "2.0.1",
"dependencies": [
{
"path": "registry.npmjs.org/d/1.0.0",
"path": "d@1.0.0",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -21,7 +21,7 @@
"version": "1.0.0",
"dependencies": [
{
"path": "registry.npmjs.org/es5-ext/0.10.24",
"path": "es5-ext@0.10.24",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -31,7 +31,7 @@
"version": "0.10.24",
"dependencies": [
{
"path": "registry.npmjs.org/es6-iterator/2.0.1",
"path": "es6-iterator@2.0.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -42,7 +42,7 @@
"circular": true
},
{
"path": "registry.npmjs.org/es6-symbol/3.1.1",
"path": "es6-symbol@3.1.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -52,7 +52,7 @@
"version": "3.1.1",
"dependencies": [
{
"path": "registry.npmjs.org/d/1.0.0",
"path": "d@1.0.0",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -63,7 +63,7 @@
"circular": true
},
{
"path": "registry.npmjs.org/es5-ext/0.10.24",
"path": "es5-ext@0.10.24",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -80,7 +80,7 @@
]
},
{
"path": "registry.npmjs.org/es5-ext/0.10.24",
"path": "es5-ext@0.10.24",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -90,7 +90,7 @@
"version": "0.10.24",
"dependencies": [
{
"path": "registry.npmjs.org/es6-iterator/2.0.1",
"path": "es6-iterator@2.0.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -101,7 +101,7 @@
"circular": true
},
{
"path": "registry.npmjs.org/es6-symbol/3.1.1",
"path": "es6-symbol@3.1.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -111,7 +111,7 @@
"version": "3.1.1",
"dependencies": [
{
"path": "registry.npmjs.org/d/1.0.0",
"path": "d@1.0.0",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -121,7 +121,7 @@
"version": "1.0.0",
"dependencies": [
{
"path": "registry.npmjs.org/es5-ext/0.10.24",
"path": "es5-ext@0.10.24",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -134,7 +134,7 @@
]
},
{
"path": "registry.npmjs.org/es5-ext/0.10.24",
"path": "es5-ext@0.10.24",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -149,7 +149,7 @@
]
},
{
"path": "registry.npmjs.org/es6-symbol/3.1.1",
"path": "es6-symbol@3.1.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -159,7 +159,7 @@
"version": "3.1.1",
"dependencies": [
{
"path": "registry.npmjs.org/d/1.0.0",
"path": "d@1.0.0",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -169,7 +169,7 @@
"version": "1.0.0",
"dependencies": [
{
"path": "registry.npmjs.org/es5-ext/0.10.24",
"path": "es5-ext@0.10.24",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -179,7 +179,7 @@
"version": "0.10.24",
"dependencies": [
{
"path": "registry.npmjs.org/es6-iterator/2.0.1",
"path": "es6-iterator@2.0.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -190,7 +190,7 @@
"circular": true
},
{
"path": "registry.npmjs.org/es6-symbol/3.1.1",
"path": "es6-symbol@3.1.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -205,7 +205,7 @@
]
},
{
"path": "registry.npmjs.org/es5-ext/0.10.24",
"path": "es5-ext@0.10.24",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -215,7 +215,7 @@
"version": "0.10.24",
"dependencies": [
{
"path": "registry.npmjs.org/es6-iterator/2.0.1",
"path": "es6-iterator@2.0.1",
"dev": false,
"isMissing": false,
"isPeer": false,
@@ -226,7 +226,7 @@
"circular": true
},
{
"path": "registry.npmjs.org/es6-symbol/3.1.1",
"path": "es6-symbol@3.1.1",
"dev": false,
"isMissing": false,
"isPeer": false,

View File

@@ -4,12 +4,12 @@ import dh, { PackageNode } from 'dependencies-hierarchy'
import path = require('path')
import test = require('tape')
const fixtures = path.join(__dirname, '..', 'fixtures')
const fixtures = path.join(__dirname, '../../../fixtures')
const generalFixture = path.join(fixtures, 'general')
const withPeerFixture = path.join(fixtures, 'with-peer')
const circularFixture = path.join(fixtures, 'circular')
const withFileDepFixture = path.join(fixtures, 'with-file-dep')
const withLinksOnlyFixture = path.join(__dirname, '..', 'fixtureWithLinks', 'with-links-only')
const withLinksOnlyFixture = path.join(fixtures, 'fixtureWithLinks/with-links-only')
const withUnsavedDepsFixture = path.join(fixtures, 'with-unsaved-deps')
const fixtureMonorepo = path.join(__dirname, '..', 'fixtureMonorepo')
const withAliasedDepFixture = path.join(fixtures, 'with-aliased-dep')
@@ -28,7 +28,7 @@ test('one package depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'minimatch',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/minimatch/3.0.4'),
path: path.join(modulesDir, '.pnpm/minimatch@3.0.4'),
resolved: 'https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz',
version: '3.0.4',
},
@@ -39,7 +39,7 @@ test('one package depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'rimraf',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/rimraf/2.5.1'),
path: path.join(modulesDir, '.pnpm/rimraf@2.5.1'),
resolved: 'https://registry.npmjs.org/rimraf/-/rimraf-2.5.1.tgz',
version: '2.5.1',
},
@@ -52,7 +52,7 @@ test('one package depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'is-positive',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/is-positive/1.0.0'),
path: path.join(modulesDir, '.pnpm/is-positive@1.0.0'),
resolved: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
version: '1.0.0',
},
@@ -66,7 +66,7 @@ test('one package depth 0', async t => {
isSkipped: false,
name: 'is-negative',
optional: true,
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/is-negative/1.0.0'),
path: path.join(modulesDir, '.pnpm/is-negative@1.0.0'),
resolved: 'https://registry.npmjs.org/is-negative/-/is-negative-1.0.0.tgz',
version: '1.0.0',
},
@@ -91,7 +91,7 @@ test('one package depth 1', async t => {
isPeer: false,
isSkipped: false,
name: 'minimatch',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/minimatch/3.0.4'),
path: path.join(modulesDir, '.pnpm/minimatch@3.0.4'),
resolved: 'https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz',
version: '3.0.4',
@@ -103,7 +103,7 @@ test('one package depth 1', async t => {
isPeer: false,
isSkipped: false,
name: 'brace-expansion',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/brace-expansion/1.1.8'),
path: path.join(modulesDir, '.pnpm/brace-expansion@1.1.8'),
resolved: 'https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz',
version: '1.1.8',
},
@@ -116,7 +116,7 @@ test('one package depth 1', async t => {
isPeer: false,
isSkipped: false,
name: 'rimraf',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/rimraf/2.5.1'),
path: path.join(modulesDir, '.pnpm/rimraf@2.5.1'),
resolved: 'https://registry.npmjs.org/rimraf/-/rimraf-2.5.1.tgz',
version: '2.5.1',
@@ -128,7 +128,7 @@ test('one package depth 1', async t => {
isPeer: false,
isSkipped: false,
name: 'glob',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/glob/6.0.4'),
path: path.join(modulesDir, '.pnpm/glob@6.0.4'),
resolved: 'https://registry.npmjs.org/glob/-/glob-6.0.4.tgz',
version: '6.0.4',
},
@@ -143,7 +143,7 @@ test('one package depth 1', async t => {
isPeer: false,
isSkipped: false,
name: 'is-positive',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/is-positive/1.0.0'),
path: path.join(modulesDir, '.pnpm/is-positive@1.0.0'),
resolved: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
version: '1.0.0',
},
@@ -157,7 +157,7 @@ test('one package depth 1', async t => {
isSkipped: false,
name: 'is-negative',
optional: true,
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/is-negative/1.0.0'),
path: path.join(modulesDir, '.pnpm/is-negative@1.0.0'),
resolved: 'https://registry.npmjs.org/is-negative/-/is-negative-1.0.0.tgz',
version: '1.0.0',
},
@@ -193,7 +193,7 @@ test('only prod depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'minimatch',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/minimatch/3.0.4'),
path: path.join(modulesDir, '.pnpm/minimatch@3.0.4'),
resolved: 'https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz',
version: '3.0.4',
},
@@ -204,7 +204,7 @@ test('only prod depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'rimraf',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/rimraf/2.5.1'),
path: path.join(modulesDir, '.pnpm/rimraf@2.5.1'),
resolved: 'https://registry.npmjs.org/rimraf/-/rimraf-2.5.1.tgz',
version: '2.5.1',
},
@@ -240,7 +240,7 @@ test('only dev depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'is-positive',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/is-positive/1.0.0'),
path: path.join(modulesDir, '.pnpm/is-positive@1.0.0'),
resolved: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
version: '1.0.0',
},
@@ -290,7 +290,7 @@ test('filter 1 package with depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'rimraf',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/rimraf/2.5.1'),
path: path.join(modulesDir, '.pnpm/rimraf@2.5.1'),
resolved: 'https://registry.npmjs.org/rimraf/-/rimraf-2.5.1.tgz',
searched: true,
version: '2.5.1',
@@ -361,7 +361,7 @@ test('local package depth 0', async t => {
isPeer: false,
isSkipped: false,
name: 'is-positive',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/is-positive/3.1.0'),
path: path.join(modulesDir, '.pnpm/is-positive@3.1.0'),
resolved: 'https://registry.npmjs.org/is-positive/-/is-positive-3.1.0.tgz',
version: '3.1.0',
},
@@ -386,7 +386,7 @@ test('on a package that has only links', async t => {
isPeer: false,
isSkipped: false,
name: 'general',
path: path.join(__dirname, '..', 'fixtureWithLinks', 'general'),
path: path.join(fixtures, 'fixtureWithLinks/general'),
version: 'link:../general',
},
],
@@ -412,7 +412,7 @@ test('unsaved dependencies are listed', async t => {
isPeer: false,
isSkipped: false,
name: 'symlink-dir',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/symlink-dir/2.0.2'),
path: path.join(modulesDir, '.pnpm/symlink-dir@2.0.2'),
resolved: 'https://registry.npmjs.org/symlink-dir/-/symlink-dir-2.0.2.tgz',
version: '2.0.2',
},
@@ -429,15 +429,6 @@ test('unsaved dependencies are listed', async t => {
path: generalFixture,
version: 'link:../general',
},
{
alias: 'is-positive',
isMissing: false,
isPeer: false,
isSkipped: false,
name: 'is-positive',
path: path.join(modulesDir, 'is-positive'),
version: '3.1.0',
},
],
},
}
@@ -466,7 +457,7 @@ test('unsaved dependencies are listed and filtered', async t => {
isPeer: false,
isSkipped: false,
name: 'symlink-dir',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/symlink-dir/2.0.2'),
path: path.join(modulesDir, '.pnpm/symlink-dir@2.0.2'),
resolved: 'https://registry.npmjs.org/symlink-dir/-/symlink-dir-2.0.2.tgz',
searched: true,
version: '2.0.2',
@@ -500,7 +491,7 @@ test('dependency with an alias', async t => {
isPeer: false,
isSkipped: false,
name: 'is-positive',
path: path.join(modulesDir, '.pnpm/registry.npmjs.org/is-positive/1.0.0'),
path: path.join(modulesDir, '.pnpm/is-positive@1.0.0'),
resolved: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
version: '1.0.0',
},

View File

@@ -1 +0,0 @@
!node_modules

View File

@@ -1,13 +0,0 @@
importers:
pkg:
hoistedAliases: {}
shamefullyFlatten: false
included:
dependencies: true
devDependencies: true
optionalDependencies: true
layoutVersion: 1
packageManager: pnpm@2.17.0-4
pendingBuilds: []
skipped: []
store: /home/zoltan/.pnpm-store/2

View File

@@ -1,14 +0,0 @@
importers:
pkg:
dependencies:
is-positive: 1.0.0
specifiers:
is-positive: 1.0.0
lockfileVersion: 5
packages:
/is-positive/1.0.0:
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=

View File

@@ -1,9 +0,0 @@
'use strict';
module.exports = function (n) {
if (typeof n !== 'number') {
throw new TypeError('Expected a number');
}
return n >= 0;
};

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Kevin Martensson <kevinmartensson@gmail.com> (github.com/kevva)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.

View File

@@ -1,29 +0,0 @@
{
"name": "is-positive",
"version": "1.0.0",
"description": "Test if a number is positive",
"license": "MIT",
"repository": "kevva/is-positive",
"author": {
"name": "Kevin Martensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js"
},
"files": [
"index.js"
],
"keywords": [
"number",
"positive",
"test"
],
"devDependencies": {
"ava": "^0.0.4"
}
}

View File

@@ -1,31 +0,0 @@
# is-positive [![Build Status](https://travis-ci.org/kevva/is-positive.svg?branch=master)](https://travis-ci.org/kevva/is-positive)
> Test if a number is positive
## Install
```
$ npm install --save is-positive
```
## Usage
```js
var isPositive = require('is-positive');
isPositive(1);
//=> true
isPositive(0);
//=> true
isPositive(-1);
//=> false
```
## License
MIT © [Kevin Martensson](http://github.com/kevva)

View File

@@ -1 +0,0 @@
../../../../../../../../../.pnpm-store/2/registry.npmjs.org/is-positive/1.0.0/node_modules/is-positive

View File

@@ -1 +0,0 @@
!node_modules

View File

@@ -1,11 +0,0 @@
included:
dependencies: true
devDependencies: true
optionalDependencies: true
layoutVersion: 3
packageManager: pnpm@3.8.1
pendingBuilds: []
registries:
default: 'https://registry.npmjs.org/'
skipped: []
store: /home/zoltan/.pnpm-store/2

View File

@@ -1,94 +0,0 @@
dependencies:
write-json-file: 2.3.0
devDependencies:
is-positive: 3.1.0
lockfileVersion: 5.1
optionalDependencies:
is-negative: 2.1.0
packages:
/detect-indent/5.0.0:
dev: false
engines:
node: '>=4'
resolution:
integrity: sha1-OHHMCmoALow+Wzz38zYmRnXwa50=
/graceful-fs/4.2.2:
dev: false
resolution:
integrity: sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==
/imurmurhash/0.1.4:
dev: false
engines:
node: '>=0.8.19'
resolution:
integrity: sha1-khi5srkoojixPcT7a21XbyMUU+o=
/is-negative/2.1.0:
dev: false
engines:
node: '>=0.10.0'
optional: true
resolution:
integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=
/is-plain-obj/1.1.0:
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha1-caUMhCnfync8kqOQpKA7OfzVHT4=
/is-positive/3.1.0:
dev: true
engines:
node: '>=0.10.0'
resolution:
integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=
/make-dir/1.3.0:
dependencies:
pify: 3.0.0
dev: false
engines:
node: '>=4'
resolution:
integrity: sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==
/pify/3.0.0:
dev: false
engines:
node: '>=4'
resolution:
integrity: sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=
/signal-exit/3.0.2:
dev: false
resolution:
integrity: sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=
/sort-keys/2.0.0:
dependencies:
is-plain-obj: 1.1.0
dev: false
engines:
node: '>=4'
resolution:
integrity: sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=
/write-file-atomic/2.4.3:
dependencies:
graceful-fs: 4.2.2
imurmurhash: 0.1.4
signal-exit: 3.0.2
dev: false
resolution:
integrity: sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==
/write-json-file/2.3.0:
dependencies:
detect-indent: 5.0.0
graceful-fs: 4.2.2
make-dir: 1.3.0
pify: 3.0.0
sort-keys: 2.0.0
write-file-atomic: 2.4.3
dev: false
engines:
node: '>=4'
resolution:
integrity: sha1-K2TIozAE1UuGmMdtWFp3zrYdoy8=
specifiers:
is-negative: ^2.1.0
is-positive: ^3.1.0
write-json-file: ^2.2.0

View File

@@ -1,85 +0,0 @@
'use strict';
const fs = require('fs');
const path = require('path');
const pify = require('pify');
const defaults = {
mode: 0o777 & (~process.umask()),
fs
};
// https://github.com/nodejs/node/issues/8987
// https://github.com/libuv/libuv/pull/1088
const checkPath = pth => {
if (process.platform === 'win32') {
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
if (pathHasInvalidWinCharacters) {
const err = new Error(`Path contains invalid characters: ${pth}`);
err.code = 'EINVAL';
throw err;
}
}
};
module.exports = (input, opts) => Promise.resolve().then(() => {
checkPath(input);
opts = Object.assign({}, defaults, opts);
const mkdir = pify(opts.fs.mkdir);
const stat = pify(opts.fs.stat);
const make = pth => {
return mkdir(pth, opts.mode)
.then(() => pth)
.catch(err => {
if (err.code === 'ENOENT') {
if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
throw err;
}
return make(path.dirname(pth)).then(() => make(pth));
}
return stat(pth)
.then(stats => stats.isDirectory() ? pth : Promise.reject())
.catch(() => {
throw err;
});
});
};
return make(path.resolve(input));
});
module.exports.sync = (input, opts) => {
checkPath(input);
opts = Object.assign({}, defaults, opts);
const make = pth => {
try {
opts.fs.mkdirSync(pth, opts.mode);
} catch (err) {
if (err.code === 'ENOENT') {
if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
throw err;
}
make(path.dirname(pth));
return make(pth);
}
try {
if (!opts.fs.statSync(pth).isDirectory()) {
throw new Error('The path is not a directory');
}
} catch (_) {
throw err;
}
}
return pth;
};
return make(path.resolve(input));
};

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.

View File

@@ -1,54 +0,0 @@
{
"name": "make-dir",
"version": "1.3.0",
"description": "Make a directory and its parents if needed - Think `mkdir -p`",
"license": "MIT",
"repository": "sindresorhus/make-dir",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && nyc ava"
},
"files": [
"index.js"
],
"keywords": [
"mkdir",
"mkdirp",
"make",
"directories",
"dir",
"dirs",
"folders",
"directory",
"folder",
"path",
"parent",
"parents",
"intermediate",
"recursively",
"recursive",
"create",
"fs",
"filesystem",
"file-system"
],
"dependencies": {
"pify": "^3.0.0"
},
"devDependencies": {
"ava": "*",
"codecov": "^3.0.0",
"graceful-fs": "^4.1.11",
"nyc": "^11.3.0",
"path-type": "^3.0.0",
"tempy": "^0.2.1",
"xo": "^0.20.0"
}
}

View File

@@ -1,116 +0,0 @@
# make-dir [![Build Status: macOS & Linux](https://travis-ci.org/sindresorhus/make-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/make-dir) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/e0vtt8y600w91gcs/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/make-dir/branch/master) [![codecov](https://codecov.io/gh/sindresorhus/make-dir/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/make-dir)
> Make a directory and its parents if needed - Think `mkdir -p`
## Advantages over [`mkdirp`](https://github.com/substack/node-mkdirp)
- Promise API *(Async/await ready!)*
- Fixes many `mkdirp` issues: [#96](https://github.com/substack/node-mkdirp/pull/96) [#70](https://github.com/substack/node-mkdirp/issues/70) [#66](https://github.com/substack/node-mkdirp/issues/66)
- 100% test coverage
- CI-tested on macOS, Linux, and Windows
- Actively maintained
- Doesn't bundle a CLI
## Install
```
$ npm install make-dir
```
## Usage
```
$ pwd
/Users/sindresorhus/fun
$ tree
.
```
```js
const makeDir = require('make-dir');
makeDir('unicorn/rainbow/cake').then(path => {
console.log(path);
//=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
});
```
```
$ tree
.
└── unicorn
└── rainbow
└── cake
```
Multiple directories:
```js
const makeDir = require('make-dir');
Promise.all([
makeDir('unicorn/rainbow')
makeDir('foo/bar')
]).then(paths => {
console.log(paths);
/*
[
'/Users/sindresorhus/fun/unicorn/rainbow',
'/Users/sindresorhus/fun/foo/bar'
]
*/
});
```
## API
### makeDir(path, [options])
Returns a `Promise` for the path to the created directory.
### makeDir.sync(path, [options])
Returns the path to the created directory.
#### path
Type: `string`
Directory to create.
#### options
Type: `Object`
##### mode
Type: `integer`<br>
Default: `0o777 & (~process.umask())`
Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
##### fs
Type: `Object`<br>
Default: `require('fs')`
Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
## Related
- [make-dir-cli](https://github.com/sindresorhus/make-dir-cli) - CLI for this module
- [del](https://github.com/sindresorhus/del) - Delete files and directories
- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching
- [cpy](https://github.com/sindresorhus/cpy) - Copy files
- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line
- [move-file](https://github.com/sindresorhus/move-file) - Move a file
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/pify/3.0.0/node_modules/pify

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/is-plain-obj/1.1.0/node_modules/is-plain-obj

View File

@@ -1,55 +0,0 @@
'use strict';
const isPlainObj = require('is-plain-obj');
module.exports = (obj, opts) => {
if (!isPlainObj(obj)) {
throw new TypeError('Expected a plain object');
}
opts = opts || {};
// DEPRECATED
if (typeof opts === 'function') {
throw new TypeError('Specify the compare function as an option instead');
}
const deep = opts.deep;
const seenInput = [];
const seenOutput = [];
const sortKeys = x => {
const seenIndex = seenInput.indexOf(x);
if (seenIndex !== -1) {
return seenOutput[seenIndex];
}
const ret = {};
const keys = Object.keys(x).sort(opts.compare);
seenInput.push(x);
seenOutput.push(ret);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const val = x[key];
if (deep && Array.isArray(val)) {
const retArr = [];
for (let j = 0; j < val.length; j++) {
retArr[j] = isPlainObj(val[j]) ? sortKeys(val[j]) : val[j];
}
ret[key] = retArr;
continue;
}
ret[key] = deep && isPlainObj(val) ? sortKeys(val) : val;
}
return ret;
};
return sortKeys(obj);
};

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.

View File

@@ -1,40 +0,0 @@
{
"name": "sort-keys",
"version": "2.0.0",
"description": "Sort the keys of an object",
"license": "MIT",
"repository": "sindresorhus/sort-keys",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"sort",
"object",
"keys",
"obj",
"key",
"stable",
"deterministic",
"deep",
"recursive",
"recursively"
],
"dependencies": {
"is-plain-obj": "^1.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
}

View File

@@ -1,60 +0,0 @@
# sort-keys [![Build Status](https://travis-ci.org/sindresorhus/sort-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/sort-keys)
> Sort the keys of an object
Useful to get a deterministically ordered object, as the order of keys can vary between engines.
## Install
```
$ npm install --save sort-keys
```
## Usage
```js
const sortKeys = require('sort-keys');
sortKeys({c: 0, a: 0, b: 0});
//=> {a: 0, b: 0, c: 0}
sortKeys({b: {b: 0, a: 0}, a: 0}, {deep: true});
//=> {a: 0, b: {a: 0, b: 0}}
sortKeys({c: 0, a: 0, b: 0}, {
compare: (a, b) => -a.localeCompare(b)
});
//=> {c: 0, b: 0, a: 0}
```
## API
### sortKeys(input, [options])
Returns a new object with sorted keys.
#### input
Type: `Object`
#### options
##### deep
Type: `boolean`
Recursively sort keys.
##### compare
Type: `Function`
[Compare function.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/graceful-fs/4.2.2/node_modules/graceful-fs

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/imurmurhash/0.1.4/node_modules/imurmurhash

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/signal-exit/3.0.2/node_modules/signal-exit

View File

@@ -1,25 +0,0 @@
# 2.4.3
* Ignore errors raised by `fs.closeSync` when cleaning up after a write
error.
# 2.4.2
* A pair of patches to fix some fd leaks. We would leak fds with sync use
when errors occured and with async use any time fsync was not in use. (#34)
# 2.4.1
* Fix a bug where `signal-exit` instances would be leaked. This was fixed when addressing #35.
# 2.4.0
## Features
* Allow chown and mode options to be set to false to disable the defaulting behavior. (#20)
* Support passing encoding strings in options slot for compat with Node.js API. (#31)
* Add support for running inside of worker threads (#37)
## Fixes
* Remove unneeded call when returning success (#36)

View File

@@ -1,6 +0,0 @@
Copyright (c) 2015, Rebecca Turner
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@@ -1,56 +0,0 @@
write-file-atomic
-----------------
This is an extension for node's `fs.writeFile` that makes its operation
atomic and allows you set ownership (uid/gid of the file).
### var writeFileAtomic = require('write-file-atomic')<br>writeFileAtomic(filename, data, [options], callback)
* filename **String**
* data **String** | **Buffer**
* options **Object** | **String**
* chown **Object** default, uid & gid of existing file, if any
* uid **Number**
* gid **Number**
* encoding **String** | **Null** default = 'utf8'
* fsync **Boolean** default = true
* mode **Number** default, from existing file, if any
* Promise **Object** default = native Promise object
* callback **Function**
Atomically and asynchronously writes data to a file, replacing the file if it already
exists. data can be a string or a buffer.
The file is initially named `filename + "." + murmurhex(__filename, process.pid, ++invocations)`.
Note that `require('worker_threads').threadId` is used in addition to `process.pid` if running inside of a worker thread.
If writeFile completes successfully then, if passed the **chown** option it will change
the ownership of the file. Finally it renames the file back to the filename you specified. If
it encounters errors at any of these steps it will attempt to unlink the temporary file and then
pass the error back to the caller.
If multiple writes are concurrently issued to the same file, the write operations are put into a queue and serialized in the order they were called, using Promises. Native promises are used by default, but you can inject your own promise-like object with the **Promise** option. Writes to different files are still executed in parallel.
If provided, the **chown** option requires both **uid** and **gid** properties or else
you'll get an error. If **chown** is not specified it will default to using
the owner of the previous file. To prevent chown from being ran you can
also pass `false`, in which case the file will be created with the current user's credentials.
If **mode** is not specified, it will default to using the permissions from
an existing file, if any. Expicitly setting this to `false` remove this default, resulting
in a file created with the system default permissions.
If options is a String, it's assumed to be the **encoding** option. The **encoding** option is ignored if **data** is a buffer. It defaults to 'utf8'.
If the **fsync** option is **false**, writeFile will skip the final fsync call.
Example:
```javascript
writeFileAtomic('message.txt', 'Hello Node', {chown:{uid:100,gid:50}}, function (err) {
if (err) throw err;
console.log('It\'s saved!');
});
```
### var writeFileAtomicSync = require('write-file-atomic').sync<br>writeFileAtomicSync(filename, data, [options])
The synchronous version of **writeFileAtomic**.

View File

@@ -1,238 +0,0 @@
'use strict'
module.exports = writeFile
module.exports.sync = writeFileSync
module.exports._getTmpname = getTmpname // for testing
module.exports._cleanupOnExit = cleanupOnExit
var fs = require('graceful-fs')
var MurmurHash3 = require('imurmurhash')
var onExit = require('signal-exit')
var path = require('path')
var activeFiles = {}
// if we run inside of a worker_thread, `process.pid` is not unique
/* istanbul ignore next */
var threadId = (function getId () {
try {
var workerThreads = require('worker_threads')
/// if we are in main thread, this is set to `0`
return workerThreads.threadId
} catch (e) {
// worker_threads are not available, fallback to 0
return 0
}
})()
var invocations = 0
function getTmpname (filename) {
return filename + '.' +
MurmurHash3(__filename)
.hash(String(process.pid))
.hash(String(threadId))
.hash(String(++invocations))
.result()
}
function cleanupOnExit (tmpfile) {
return function () {
try {
fs.unlinkSync(typeof tmpfile === 'function' ? tmpfile() : tmpfile)
} catch (_) {}
}
}
function writeFile (filename, data, options, callback) {
if (options) {
if (options instanceof Function) {
callback = options
options = {}
} else if (typeof options === 'string') {
options = { encoding: options }
}
} else {
options = {}
}
var Promise = options.Promise || global.Promise
var truename
var fd
var tmpfile
/* istanbul ignore next -- The closure only gets called when onExit triggers */
var removeOnExitHandler = onExit(cleanupOnExit(() => tmpfile))
var absoluteName = path.resolve(filename)
new Promise(function serializeSameFile (resolve) {
// make a queue if it doesn't already exist
if (!activeFiles[absoluteName]) activeFiles[absoluteName] = []
activeFiles[absoluteName].push(resolve) // add this job to the queue
if (activeFiles[absoluteName].length === 1) resolve() // kick off the first one
}).then(function getRealPath () {
return new Promise(function (resolve) {
fs.realpath(filename, function (_, realname) {
truename = realname || filename
tmpfile = getTmpname(truename)
resolve()
})
})
}).then(function stat () {
return new Promise(function stat (resolve) {
if (options.mode && options.chown) resolve()
else {
// Either mode or chown is not explicitly set
// Default behavior is to copy it from original file
fs.stat(truename, function (err, stats) {
if (err || !stats) resolve()
else {
options = Object.assign({}, options)
if (options.mode == null) {
options.mode = stats.mode
}
if (options.chown == null && process.getuid) {
options.chown = { uid: stats.uid, gid: stats.gid }
}
resolve()
}
})
}
})
}).then(function thenWriteFile () {
return new Promise(function (resolve, reject) {
fs.open(tmpfile, 'w', options.mode, function (err, _fd) {
fd = _fd
if (err) reject(err)
else resolve()
})
})
}).then(function write () {
return new Promise(function (resolve, reject) {
if (Buffer.isBuffer(data)) {
fs.write(fd, data, 0, data.length, 0, function (err) {
if (err) reject(err)
else resolve()
})
} else if (data != null) {
fs.write(fd, String(data), 0, String(options.encoding || 'utf8'), function (err) {
if (err) reject(err)
else resolve()
})
} else resolve()
})
}).then(function syncAndClose () {
return new Promise(function (resolve, reject) {
if (options.fsync !== false) {
fs.fsync(fd, function (err) {
if (err) fs.close(fd, () => reject(err))
else fs.close(fd, resolve)
})
} else {
fs.close(fd, resolve)
}
})
}).then(function chown () {
fd = null
if (options.chown) {
return new Promise(function (resolve, reject) {
fs.chown(tmpfile, options.chown.uid, options.chown.gid, function (err) {
if (err) reject(err)
else resolve()
})
})
}
}).then(function chmod () {
if (options.mode) {
return new Promise(function (resolve, reject) {
fs.chmod(tmpfile, options.mode, function (err) {
if (err) reject(err)
else resolve()
})
})
}
}).then(function rename () {
return new Promise(function (resolve, reject) {
fs.rename(tmpfile, truename, function (err) {
if (err) reject(err)
else resolve()
})
})
}).then(function success () {
removeOnExitHandler()
callback()
}, function fail (err) {
return new Promise(resolve => {
return fd ? fs.close(fd, resolve) : resolve()
}).then(() => {
removeOnExitHandler()
fs.unlink(tmpfile, function () {
callback(err)
})
})
}).then(function checkQueue () {
activeFiles[absoluteName].shift() // remove the element added by serializeSameFile
if (activeFiles[absoluteName].length > 0) {
activeFiles[absoluteName][0]() // start next job if one is pending
} else delete activeFiles[absoluteName]
})
}
function writeFileSync (filename, data, options) {
if (typeof options === 'string') options = { encoding: options }
else if (!options) options = {}
try {
filename = fs.realpathSync(filename)
} catch (ex) {
// it's ok, it'll happen on a not yet existing file
}
var tmpfile = getTmpname(filename)
if (!options.mode || !options.chown) {
// Either mode or chown is not explicitly set
// Default behavior is to copy it from original file
try {
var stats = fs.statSync(filename)
options = Object.assign({}, options)
if (!options.mode) {
options.mode = stats.mode
}
if (!options.chown && process.getuid) {
options.chown = { uid: stats.uid, gid: stats.gid }
}
} catch (ex) {
// ignore stat errors
}
}
var fd
var cleanup = cleanupOnExit(tmpfile)
var removeOnExitHandler = onExit(cleanup)
try {
fd = fs.openSync(tmpfile, 'w', options.mode)
if (Buffer.isBuffer(data)) {
fs.writeSync(fd, data, 0, data.length, 0)
} else if (data != null) {
fs.writeSync(fd, String(data), 0, String(options.encoding || 'utf8'))
}
if (options.fsync !== false) {
fs.fsyncSync(fd)
}
fs.closeSync(fd)
if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
if (options.mode) fs.chmodSync(tmpfile, options.mode)
fs.renameSync(tmpfile, filename)
removeOnExitHandler()
} catch (err) {
if (fd) {
try {
fs.closeSync(fd)
} catch (ex) {
// ignore close errors at this stage, error may have closed fd already.
}
}
removeOnExitHandler()
cleanup()
throw err
}
}

View File

@@ -1,41 +0,0 @@
{
"name": "write-file-atomic",
"version": "2.4.3",
"description": "Write files in an atomic fashion w/configurable ownership",
"main": "index.js",
"scripts": {
"test": "standard && tap --100 test/*.js",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --follow-tags"
},
"repository": {
"type": "git",
"url": "git@github.com:iarna/write-file-atomic.git"
},
"keywords": [
"writeFile",
"atomic"
],
"author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org)",
"license": "ISC",
"bugs": {
"url": "https://github.com/iarna/write-file-atomic/issues"
},
"homepage": "https://github.com/iarna/write-file-atomic",
"dependencies": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
"signal-exit": "^3.0.2"
},
"devDependencies": {
"mkdirp": "^0.5.1",
"require-inject": "^1.4.0",
"rimraf": "^2.5.4",
"standard": "^12.0.1",
"tap": "^12.1.3"
},
"files": [
"index.js"
]
}

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/detect-indent/5.0.0/node_modules/detect-indent

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/graceful-fs/4.2.2/node_modules/graceful-fs

View File

@@ -1 +0,0 @@
../../../make-dir/1.3.0/node_modules/make-dir

View File

@@ -1 +0,0 @@
../../../../../../../../../../../../../.pnpm-store/2/registry.npmjs.org/pify/3.0.0/node_modules/pify

View File

@@ -1 +0,0 @@
../../../sort-keys/2.0.0/node_modules/sort-keys

View File

@@ -1 +0,0 @@
../../../write-file-atomic/2.4.3/node_modules/write-file-atomic

View File

@@ -1,73 +0,0 @@
'use strict';
const path = require('path');
const fs = require('graceful-fs');
const writeFileAtomic = require('write-file-atomic');
const sortKeys = require('sort-keys');
const makeDir = require('make-dir');
const pify = require('pify');
const detectIndent = require('detect-indent');
const init = (fn, fp, data, opts) => {
if (!fp) {
throw new TypeError('Expected a filepath');
}
if (data === undefined) {
throw new TypeError('Expected data to stringify');
}
opts = Object.assign({
indent: '\t',
sortKeys: false
}, opts);
if (opts.sortKeys) {
data = sortKeys(data, {
deep: true,
compare: typeof opts.sortKeys === 'function' && opts.sortKeys
});
}
return fn(fp, data, opts);
};
const readFile = fp => pify(fs.readFile)(fp, 'utf8').catch(() => {});
const main = (fp, data, opts) => {
return (opts.detectIndent ? readFile(fp) : Promise.resolve())
.then(str => {
const indent = str ? detectIndent(str).indent : opts.indent;
const json = JSON.stringify(data, opts.replacer, indent);
return pify(writeFileAtomic)(fp, `${json}\n`, {mode: opts.mode});
});
};
const mainSync = (fp, data, opts) => {
let indent = opts.indent;
if (opts.detectIndent) {
try {
const file = fs.readFileSync(fp, 'utf8');
indent = detectIndent(file).indent;
} catch (err) {
if (err.code !== 'ENOENT') {
throw err;
}
}
}
const json = JSON.stringify(data, opts.replacer, indent);
return writeFileAtomic.sync(fp, `${json}\n`, {mode: opts.mode});
};
module.exports = (fp, data, opts) => {
return makeDir(path.dirname(fp), {fs})
.then(() => init(main, fp, data, opts));
};
module.exports.sync = (fp, data, opts) => {
makeDir.sync(path.dirname(fp), {fs});
init(mainSync, fp, data, opts);
};

View File

@@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.

View File

@@ -1,48 +0,0 @@
{
"name": "write-json-file",
"version": "2.3.0",
"description": "Stringify and write JSON to a file atomically",
"license": "MIT",
"repository": "sindresorhus/write-json-file",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"write",
"json",
"stringify",
"file",
"fs",
"graceful",
"stable",
"sort",
"newline",
"indent",
"atomic",
"atomically"
],
"dependencies": {
"detect-indent": "^5.0.0",
"graceful-fs": "^4.1.2",
"make-dir": "^1.0.0",
"pify": "^3.0.0",
"sort-keys": "^2.0.0",
"write-file-atomic": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"tempfile": "^2.0.0",
"xo": "*"
}
}

View File

@@ -1,83 +0,0 @@
# write-json-file [![Build Status](https://travis-ci.org/sindresorhus/write-json-file.svg?branch=master)](https://travis-ci.org/sindresorhus/write-json-file)
> Stringify and write JSON to a file [atomically](https://github.com/npm/write-file-atomic)
Creates directories for you as needed.
## Install
```
$ npm install write-json-file
```
## Usage
```js
const writeJsonFile = require('write-json-file');
writeJsonFile('foo.json', {foo: true}).then(() => {
console.log('done');
});
```
## API
### writeJsonFile(filepath, data, [options])
Returns a `Promise`.
### writeJsonFile.sync(filepath, data, [options])
#### options
Type: `Object`
##### indent
Type: `string` `number`<br>
Default: `'\t'`
Indentation as a string or number of spaces.<br>
Pass in `null` for no formatting.
##### detectIndent
Type: `boolean`<br>
Default: `false`
Detect indentation automatically if the file exists.
##### sortKeys
Type: `boolean` `function`<br>
Default: `false`
Sort the keys recursively.<br>
Optionally pass in a [`compare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) function.
##### replacer
Type: `function`
Passed into [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter).
##### mode
Type: `number`<br>
Default: `0o666`
[Mode](https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation) used when writing the file.
## Related
- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file
- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@@ -1 +0,0 @@
../../../../../../../../.pnpm-store/2/registry.npmjs.org/is-negative/2.1.0/node_modules/is-negative

View File

@@ -1 +0,0 @@
../../../../../../../../.pnpm-store/2/registry.npmjs.org/is-positive/3.1.0/node_modules/is-positive

View File

@@ -1 +0,0 @@
.pnpm/registry.npmjs.org/write-json-file/2.3.0/node_modules/write-json-file

View File

@@ -1 +0,0 @@
!node_modules

View File

@@ -1,11 +0,0 @@
included:
dependencies: true
devDependencies: true
optionalDependencies: true
layoutVersion: 3
packageManager: pnpm@3.8.1
pendingBuilds: []
registries:
default: 'https://registry.npmjs.org/'
skipped: []
store: /home/zoltan/.pnpm-store/2

Some files were not shown because too many files have changed in this diff Show More