Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/lib/content/commands/npm-stage.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Key behaviors:
version for that package.
* You can still publish packages normally while you have staged packages
pending.
* Staged publishing will allow you to create a new package if it does not exist.
* You can stage multiple versions of the same package.
* `npm stage publish` has parity with `npm publish` and will respect
`"private": true` in `package.json`, refusing to stage the package.
Expand All @@ -46,8 +47,6 @@ Before using `npm stage` commands, ensure the following requirements are met:

* **Write permissions on the package:** You must have write access to the
package you're configuring.
* **Package must exist:** The package you're configuring must already exist
on the npm registry.
* **2FA enabled on your account:** Commands that require 2FA will prompt you
to authenticate. If you don't already have 2FA enabled on your account,
you must enable it before using these commands.
Expand Down
22 changes: 21 additions & 1 deletion workspaces/config/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const t = require('tap')

const fs = require('node:fs')
const { readFileSync } = fs
const { homedir } = require('node:os')
const { resolve, join, dirname } = require('node:path')

// when running with `npm test` it adds environment variables that
// mess with the things we expect here, so delete all of those.
Expand All @@ -16,11 +18,28 @@ const createDef = (key, value) => ({ [key]: new Definition(key, { key, ...value

const typeDefs = require('../lib/type-defs.js')

const { resolve, join, dirname } = require('node:path')
const nodePrefix = process.platform === 'win32'
? dirname(process.execPath)
: dirname(dirname(process.execPath))
const externalNpmrcs = new Set([
resolve('/etc/npmrc'),
resolve(nodePrefix, 'etc/npmrc'),
resolve(homedir(), '.npmrc'),
])
const throwIfExternalNpmrc = path => {
if (typeof path === 'string' && externalNpmrcs.has(resolve(path))) {
throw Object.assign(new Error(`ENOENT: no such file or directory, open '${path}'`), {
code: 'ENOENT',
path,
syscall: 'open',
})
}
}

const mockFs = {
...fs,
readFileSync: (path, ...args) => {
throwIfExternalNpmrc(path)
if (path.includes('WEIRD-ERROR')) {
throw Object.assign(new Error('weird error'), { code: 'EWEIRD' })
}
Expand All @@ -32,6 +51,7 @@ const mockFs = {
const mockFsPromises = {
...fs.promises,
readFile: async (path, ...args) => {
throwIfExternalNpmrc(path)
if (path.includes('WEIRD-ERROR')) {
throw Object.assign(new Error('weird error'), { code: 'EWEIRD' })
}
Expand Down
Loading