diff --git a/bin/npm-prefix.js b/bin/npm-prefix.js index 3ff43de0dd84d..b0b0ace6a92ab 100755 --- a/bin/npm-prefix.js +++ b/bin/npm-prefix.js @@ -3,7 +3,7 @@ // without having to load all of npm first // It does not accept argv params -const path = require('path') +const path = require('node:path') const Config = require('@npmcli/config') const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions') const config = new Config({ diff --git a/lib/cli/entry.js b/lib/cli/entry.js index 49b13eb0234cd..ed73eb89e2d36 100644 --- a/lib/cli/entry.js +++ b/lib/cli/entry.js @@ -12,7 +12,7 @@ module.exports = async (process, validateEngines) => { } // Patch the global fs module here at the app level - require('graceful-fs').gracefulify(require('fs')) + require('graceful-fs').gracefulify(require('node:fs')) const satisfies = require('semver/functions/satisfies') const ExitHandler = require('./exit-handler.js') diff --git a/lib/cli/update-notifier.js b/lib/cli/update-notifier.js index 41fece36a558e..32cac18350be9 100644 --- a/lib/cli/update-notifier.js +++ b/lib/cli/update-notifier.js @@ -6,8 +6,8 @@ const ciInfo = require('ci-info') const gt = require('semver/functions/gt') const gte = require('semver/functions/gte') const parse = require('semver/functions/parse') -const { stat, writeFile } = require('fs/promises') -const { resolve } = require('path') +const { stat, writeFile } = require('node:fs/promises') +const { resolve } = require('node:path') // update check frequency const DAILY = 1000 * 60 * 60 * 24 diff --git a/lib/commands/cache.js b/lib/commands/cache.js index b8bef966aef1e..87c70a57dc0ed 100644 --- a/lib/commands/cache.js +++ b/lib/commands/cache.js @@ -1,7 +1,7 @@ const cacache = require('cacache') const pacote = require('pacote') -const fs = require('fs/promises') -const { join } = require('path') +const fs = require('node:fs/promises') +const { join } = require('node:path') const semver = require('semver') const BaseCommand = require('../base-cmd.js') const npa = require('npm-package-arg') diff --git a/lib/commands/ci.js b/lib/commands/ci.js index 4432aea408fbd..c190de7e3ea7f 100644 --- a/lib/commands/ci.js +++ b/lib/commands/ci.js @@ -1,7 +1,7 @@ const reifyFinish = require('../utils/reify-finish.js') const runScript = require('@npmcli/run-script') -const fs = require('fs/promises') -const path = require('path') +const fs = require('node:fs/promises') +const path = require('node:path') const { log, time } = require('proc-log') const validateLockfile = require('../utils/validate-lockfile.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') diff --git a/lib/commands/completion.js b/lib/commands/completion.js index 9b147d2f5bdac..f8c2e00c6baee 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -28,9 +28,9 @@ // one per line for the shell completion method to consume in IFS=$'\n' mode // as an array. -const fs = require('fs/promises') +const fs = require('node:fs/promises') const nopt = require('nopt') -const { resolve } = require('path') +const { resolve } = require('node:path') const { output } = require('proc-log') const Npm = require('../npm.js') const { definitions, shorthands } = require('@npmcli/config/lib/definitions') diff --git a/lib/commands/diff.js b/lib/commands/diff.js index ca8b1237b40c5..3fa8090a35046 100644 --- a/lib/commands/diff.js +++ b/lib/commands/diff.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const semver = require('semver') const libnpmdiff = require('libnpmdiff') const npa = require('npm-package-arg') diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index c29dd7e0ecb17..8fbd49b7ca8bf 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -1,9 +1,9 @@ const cacache = require('cacache') -const { access, lstat, readdir, constants: { R_OK, W_OK, X_OK } } = require('fs/promises') +const { access, lstat, readdir, constants: { R_OK, W_OK, X_OK } } = require('node:fs/promises') const fetch = require('make-fetch-happen') const which = require('which') const pacote = require('pacote') -const { resolve } = require('path') +const { resolve } = require('node:path') const semver = require('semver') const { log, output } = require('proc-log') const ping = require('../utils/ping.js') diff --git a/lib/commands/edit.js b/lib/commands/edit.js index 4110a1db55e82..b2c2ec8d2a39a 100644 --- a/lib/commands/edit.js +++ b/lib/commands/edit.js @@ -1,6 +1,6 @@ -const { resolve } = require('path') -const { lstat } = require('fs/promises') -const cp = require('child_process') +const { resolve } = require('node:path') +const { lstat } = require('node:fs/promises') +const cp = require('node:child_process') const completion = require('../utils/installed-shallow.js') const BaseCommand = require('../base-cmd.js') diff --git a/lib/commands/exec.js b/lib/commands/exec.js index 9bb4b15e0c5a3..6c2d3373ab72e 100644 --- a/lib/commands/exec.js +++ b/lib/commands/exec.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const libexec = require('libnpmexec') const BaseCommand = require('../base-cmd.js') diff --git a/lib/commands/explain.js b/lib/commands/explain.js index caaeeee1e6939..cb0644304d2b5 100644 --- a/lib/commands/explain.js +++ b/lib/commands/explain.js @@ -1,7 +1,7 @@ const { explainNode } = require('../utils/explain-dep.js') const npa = require('npm-package-arg') const semver = require('semver') -const { relative, resolve } = require('path') +const { relative, resolve } = require('node:path') const validName = require('validate-npm-package-name') const { output } = require('proc-log') const ArboristWorkspaceCmd = require('../arborist-cmd.js') diff --git a/lib/commands/explore.js b/lib/commands/explore.js index d9dd9a9931f56..184af2bdc5a16 100644 --- a/lib/commands/explore.js +++ b/lib/commands/explore.js @@ -1,6 +1,6 @@ const pkgJson = require('@npmcli/package-json') const runScript = require('@npmcli/run-script') -const { join, relative } = require('path') +const { join, relative } = require('node:path') const { log, output } = require('proc-log') const completion = require('../utils/installed-shallow.js') const BaseCommand = require('../base-cmd.js') diff --git a/lib/commands/help.js b/lib/commands/help.js index a2307bf1d8a2c..057090da0036c 100644 --- a/lib/commands/help.js +++ b/lib/commands/help.js @@ -1,5 +1,5 @@ const spawn = require('@npmcli/promise-spawn') -const path = require('path') +const path = require('node:path') const { openUrl } = require('../utils/open-url.js') const { glob } = require('glob') const { output, input } = require('proc-log') diff --git a/lib/commands/init.js b/lib/commands/init.js index 205352e86e6ed..4c68210483598 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -1,6 +1,6 @@ -const { statSync } = require('fs') -const { relative, resolve } = require('path') -const { mkdir } = require('fs/promises') +const { statSync } = require('node:fs') +const { relative, resolve } = require('node:path') +const { mkdir } = require('node:fs/promises') const initJson = require('init-package-json') const npa = require('npm-package-arg') const libexec = require('libnpmexec') diff --git a/lib/commands/link.js b/lib/commands/link.js index bde761c4226dc..8a41548d7f108 100644 --- a/lib/commands/link.js +++ b/lib/commands/link.js @@ -1,5 +1,5 @@ -const { readdir } = require('fs/promises') -const { resolve } = require('path') +const { readdir } = require('node:fs/promises') +const { resolve } = require('node:path') const npa = require('npm-package-arg') const pkgJson = require('@npmcli/package-json') const semver = require('semver') diff --git a/lib/commands/ls.js b/lib/commands/ls.js index a826b52832750..417cb1b40d8c2 100644 --- a/lib/commands/ls.js +++ b/lib/commands/ls.js @@ -1,4 +1,4 @@ -const { resolve, relative, sep } = require('path') +const { resolve, relative, sep } = require('node:path') const archy = require('archy') const { breadth } = require('treeverse') const npa = require('npm-package-arg') diff --git a/lib/commands/profile.js b/lib/commands/profile.js index d808bb820941f..965fcbcb8ce29 100644 --- a/lib/commands/profile.js +++ b/lib/commands/profile.js @@ -1,5 +1,5 @@ -const { inspect } = require('util') -const { URL } = require('url') +const { inspect } = require('node:util') +const { URL } = require('node:url') const { log, output } = require('proc-log') const { get, set, createToken } = require('npm-profile') const qrcodeTerminal = require('qrcode-terminal') diff --git a/lib/commands/rebuild.js b/lib/commands/rebuild.js index 3894f0aa290cc..1c19836106e06 100644 --- a/lib/commands/rebuild.js +++ b/lib/commands/rebuild.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const { output } = require('proc-log') const npa = require('npm-package-arg') const semver = require('semver') diff --git a/lib/commands/repo.js b/lib/commands/repo.js index 8e2fef24771d9..3f120c0a3f59f 100644 --- a/lib/commands/repo.js +++ b/lib/commands/repo.js @@ -1,4 +1,4 @@ -const { URL } = require('url') +const { URL } = require('node:url') const PackageUrlCmd = require('../package-url-cmd.js') class Repo extends PackageUrlCmd { diff --git a/lib/commands/shrinkwrap.js b/lib/commands/shrinkwrap.js index d7866bdb91dce..86215c18e62dd 100644 --- a/lib/commands/shrinkwrap.js +++ b/lib/commands/shrinkwrap.js @@ -1,5 +1,5 @@ -const { resolve, basename } = require('path') -const { unlink } = require('fs/promises') +const { resolve, basename } = require('node:path') +const { unlink } = require('node:fs/promises') const { log } = require('proc-log') const BaseCommand = require('../base-cmd.js') diff --git a/lib/commands/uninstall.js b/lib/commands/uninstall.js index 7496c02deb28f..f9baebe3bc2e2 100644 --- a/lib/commands/uninstall.js +++ b/lib/commands/uninstall.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const pkgJson = require('@npmcli/package-json') const reifyFinish = require('../utils/reify-finish.js') const completion = require('../utils/installed-shallow.js') diff --git a/lib/commands/update.js b/lib/commands/update.js index ddc3e4a47f38a..235a9a41177df 100644 --- a/lib/commands/update.js +++ b/lib/commands/update.js @@ -1,4 +1,4 @@ -const path = require('path') +const path = require('node:path') const { log } = require('proc-log') const reifyFinish = require('../utils/reify-finish.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') diff --git a/lib/commands/view.js b/lib/commands/view.js index a59b486f23e60..cf7292a2f3b81 100644 --- a/lib/commands/view.js +++ b/lib/commands/view.js @@ -1,13 +1,13 @@ const columns = require('cli-columns') -const { readFile } = require('fs/promises') +const { readFile } = require('node:fs/promises') const jsonParse = require('json-parse-even-better-errors') const { log, output, META } = require('proc-log') const npa = require('npm-package-arg') -const { resolve } = require('path') +const { resolve } = require('node:path') const formatBytes = require('../utils/format-bytes.js') const relativeDate = require('tiny-relative-date') const semver = require('semver') -const { inspect } = require('util') +const { inspect } = require('node:util') const { packument } = require('pacote') const Queryable = require('../utils/queryable.js') const BaseCommand = require('../base-cmd.js') diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index c484c1ab9c2b6..fc47c909069f0 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -97,7 +97,7 @@ const errorMessage = (er, npm) => { // Check whether we ran into a conflict in our own package.json if (er.path === resolve(npm.prefix, 'package.json')) { const { isDiff } = require('parse-conflict-json') - const txt = require('fs').readFileSync(er.path, 'utf8').replace(/\r\n/g, '\n') + const txt = require('node:fs').readFileSync(er.path, 'utf8').replace(/\r\n/g, '\n') if (isDiff(txt)) { detail.push(['', [ 'Merge conflict detected in your package.json.', diff --git a/lib/utils/format.js b/lib/utils/format.js index abfbf9e331704..aaecfe1ba0e7a 100644 --- a/lib/utils/format.js +++ b/lib/utils/format.js @@ -1,4 +1,4 @@ -const { formatWithOptions: baseFormatWithOptions } = require('util') +const { formatWithOptions: baseFormatWithOptions } = require('node:util') // These are most assuredly not a mistake // https://eslint.org/docs/latest/rules/no-control-regex diff --git a/lib/utils/get-workspaces.js b/lib/utils/get-workspaces.js index 59efb0e9f01be..48c26779bb137 100644 --- a/lib/utils/get-workspaces.js +++ b/lib/utils/get-workspaces.js @@ -1,4 +1,4 @@ -const { resolve, relative } = require('path') +const { resolve, relative } = require('node:path') const mapWorkspaces = require('@npmcli/map-workspaces') const { minimatch } = require('minimatch') const pkgJson = require('@npmcli/package-json') diff --git a/lib/utils/installed-deep.js b/lib/utils/installed-deep.js index 045708f74bd2a..3c56c5d036f25 100644 --- a/lib/utils/installed-deep.js +++ b/lib/utils/installed-deep.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const localeCompare = require('@isaacs/string-locale-compare')('en') const installedDeep = async (npm) => { diff --git a/lib/utils/log-file.js b/lib/utils/log-file.js index f8dd19d333cf6..6c9bcd7ff8d86 100644 --- a/lib/utils/log-file.js +++ b/lib/utils/log-file.js @@ -1,7 +1,7 @@ -const os = require('os') -const { join, dirname, basename } = require('path') +const os = require('node:os') +const { join, dirname, basename } = require('node:path') const fsMiniPass = require('fs-minipass') -const fs = require('fs/promises') +const fs = require('node:fs/promises') const { log } = require('proc-log') const { formatWithOptions } = require('./format') diff --git a/lib/utils/open-url.js b/lib/utils/open-url.js index 03451af207e86..632dcc79949d6 100644 --- a/lib/utils/open-url.js +++ b/lib/utils/open-url.js @@ -1,6 +1,6 @@ const { open } = require('@npmcli/promise-spawn') const { output, input } = require('proc-log') -const { URL } = require('url') +const { URL } = require('node:url') const readline = require('node:readline/promises') const { once } = require('node:events') diff --git a/lib/utils/queryable.js b/lib/utils/queryable.js index 4fc1e3533eabc..a5fb25a845eaf 100644 --- a/lib/utils/queryable.js +++ b/lib/utils/queryable.js @@ -1,4 +1,4 @@ -const util = require('util') +const util = require('node:util') const _delete = Symbol('delete') const _append = Symbol('append') diff --git a/lib/utils/reify-finish.js b/lib/utils/reify-finish.js index 0b34a37576860..410c19730cdf4 100644 --- a/lib/utils/reify-finish.js +++ b/lib/utils/reify-finish.js @@ -1,7 +1,7 @@ const reifyOutput = require('./reify-output.js') const ini = require('ini') -const { writeFile } = require('fs/promises') -const { resolve } = require('path') +const { writeFile } = require('node:fs/promises') +const { resolve } = require('node:path') const reifyFinish = async (npm, arb) => { await saveBuiltinConfig(npm, arb) diff --git a/lib/utils/sbom-cyclonedx.js b/lib/utils/sbom-cyclonedx.js index 0a340895bb3f4..989abea58dae8 100644 --- a/lib/utils/sbom-cyclonedx.js +++ b/lib/utils/sbom-cyclonedx.js @@ -1,4 +1,4 @@ -const crypto = require('crypto') +const crypto = require('node:crypto') const normalizeData = require('normalize-package-data') const parseLicense = require('spdx-expression-parse') const npa = require('npm-package-arg') diff --git a/lib/utils/sbom-spdx.js b/lib/utils/sbom-spdx.js index fdddd8944f32d..e3af77e10c751 100644 --- a/lib/utils/sbom-spdx.js +++ b/lib/utils/sbom-spdx.js @@ -1,5 +1,5 @@ -const crypto = require('crypto') +const crypto = require('node:crypto') const normalizeData = require('normalize-package-data') const npa = require('npm-package-arg') const ssri = require('ssri') diff --git a/scripts/bundle-and-gitignore-deps.js b/scripts/bundle-and-gitignore-deps.js index 1b77f170ccdb8..404162595e0e9 100644 --- a/scripts/bundle-and-gitignore-deps.js +++ b/scripts/bundle-and-gitignore-deps.js @@ -1,6 +1,6 @@ const Arborist = require('@npmcli/arborist') const packlist = require('npm-packlist') -const { join, relative } = require('path') +const { join, relative } = require('node:path') const localeCompare = require('@isaacs/string-locale-compare')('en') const PackageJson = require('@npmcli/package-json') const { run, CWD, git, fs, pkg: rootPkg, EOL } = require('./util') diff --git a/scripts/create-node-pr.js b/scripts/create-node-pr.js index b0b4856c0192f..0a8bdd35162c0 100644 --- a/scripts/create-node-pr.js +++ b/scripts/create-node-pr.js @@ -1,5 +1,5 @@ -const { join, basename } = require('path') -const fsp = require('fs/promises') +const { join, basename } = require('node:path') +const fsp = require('node:fs/promises') const hgi = require('hosted-git-info') const semver = require('semver') const pacote = require('pacote') diff --git a/scripts/dependency-graph.js b/scripts/dependency-graph.js index 6b92c65296f0a..4d80f5207d8c1 100644 --- a/scripts/dependency-graph.js +++ b/scripts/dependency-graph.js @@ -1,7 +1,7 @@ const Arborist = require('@npmcli/arborist') -const os = require('os') -const { readFileSync } = require('fs') -const { join } = require('path') +const os = require('node:os') +const { readFileSync } = require('node:fs') +const { join } = require('node:path') const { log } = require('proc-log') const { run, CWD, pkg, fs, EOL } = require('./util.js') diff --git a/scripts/fish-completion.js b/scripts/fish-completion.js index 4686befd8ba7f..bd8e92b56937b 100644 --- a/scripts/fish-completion.js +++ b/scripts/fish-completion.js @@ -1,6 +1,6 @@ /* eslint-disable no-console */ -const fs = require('fs/promises') -const { resolve } = require('path') +const fs = require('node:fs/promises') +const { resolve } = require('node:path') const { commands, aliases } = require('../lib/utils/cmd-list.js') const { definitions } = require('@npmcli/config/lib/definitions') diff --git a/scripts/resetdeps.js b/scripts/resetdeps.js index 1dd08ec892f6d..b24c83e63b019 100644 --- a/scripts/resetdeps.js +++ b/scripts/resetdeps.js @@ -1,5 +1,5 @@ -const { join } = require('path') -const { symlink } = require('fs/promises') +const { join } = require('node:path') +const { symlink } = require('node:fs/promises') const { CWD, run, pkg, fs, git, npm } = require('./util.js') const cleanup = async () => { diff --git a/scripts/update-authors.js b/scripts/update-authors.js index e95bb87bfc00a..ca139ca8b59b8 100644 --- a/scripts/update-authors.js +++ b/scripts/update-authors.js @@ -1,4 +1,4 @@ -const { join } = require('path') +const { join } = require('node:path') const { CWD, run, git, fs, EOL } = require('./util.js') const main = async () => { diff --git a/scripts/update-cli-repos.js b/scripts/update-cli-repos.js index 69949a4e351ec..a2bdb0efadf70 100644 --- a/scripts/update-cli-repos.js +++ b/scripts/update-cli-repos.js @@ -1,4 +1,4 @@ -const { join } = require('path') +const { join } = require('node:path') const { fs, gh, run } = require('./util.js') const query = ` diff --git a/scripts/util.js b/scripts/util.js index 9c9973914b1f3..f6f9cbc9300ba 100644 --- a/scripts/util.js +++ b/scripts/util.js @@ -1,6 +1,6 @@ -const fsp = require('fs/promises') -const { resolve, join, relative } = require('path') -const { formatWithOptions } = require('util') +const fsp = require('node:fs/promises') +const { resolve, join, relative } = require('node:path') +const { formatWithOptions } = require('node:util') const { log } = require('proc-log') const nopt = require('nopt') const npmGit = require('@npmcli/git') diff --git a/smoke-tests/test/fixtures/setup.js b/smoke-tests/test/fixtures/setup.js index e5302104f2503..18492d0d52f8f 100644 --- a/smoke-tests/test/fixtures/setup.js +++ b/smoke-tests/test/fixtures/setup.js @@ -1,10 +1,10 @@ -const fs = require('fs/promises') -const { existsSync } = require('fs') -const { join, resolve, sep, extname, relative, delimiter } = require('path') +const fs = require('node:fs/promises') +const { existsSync } = require('node:fs') +const { join, resolve, sep, extname, relative, delimiter } = require('node:path') const which = require('which') const spawn = require('@npmcli/promise-spawn') const MockRegistry = require('@npmcli/mock-registry') -const http = require('http') +const http = require('node:http') const { createProxy } = require('proxy') const { SMOKE_PUBLISH_TARBALL, CI, PATH, Path } = process.env diff --git a/smoke-tests/test/index.js b/smoke-tests/test/index.js index 412b0f55d8565..48ab12ea98e53 100644 --- a/smoke-tests/test/index.js +++ b/smoke-tests/test/index.js @@ -1,4 +1,4 @@ -const { join } = require('path') +const { join } = require('node:path') const t = require('tap') const setup = require('./fixtures/setup.js') diff --git a/smoke-tests/test/large-install.js b/smoke-tests/test/large-install.js index a9260c8d3f0f1..460205c673182 100644 --- a/smoke-tests/test/large-install.js +++ b/smoke-tests/test/large-install.js @@ -1,5 +1,5 @@ const t = require('tap') -const path = require('path') +const path = require('node:path') const setup = require('./fixtures/setup.js') const getFixture = (p) => require( diff --git a/smoke-tests/test/npm-replace-global.js b/smoke-tests/test/npm-replace-global.js index b7177a0fec816..3514549aa40cd 100644 --- a/smoke-tests/test/npm-replace-global.js +++ b/smoke-tests/test/npm-replace-global.js @@ -1,7 +1,7 @@ const t = require('tap') -const { join, dirname, basename, extname } = require('path') -const fs = require('fs/promises') +const { join, dirname, basename, extname } = require('node:path') +const fs = require('node:fs/promises') const _which = require('which') const setup = require('./fixtures/setup.js') diff --git a/test/bin/windows-shims.js b/test/bin/windows-shims.js index 71f12dc8e1cdd..8fbee609a0fab 100644 --- a/test/bin/windows-shims.js +++ b/test/bin/windows-shims.js @@ -1,7 +1,7 @@ const t = require('tap') -const { spawnSync } = require('child_process') -const { resolve, join, extname, basename } = require('path') -const { readFileSync, chmodSync, readdirSync, statSync } = require('fs') +const { spawnSync } = require('node:child_process') +const { resolve, join, extname, basename } = require('node:path') +const { readFileSync, chmodSync, readdirSync, statSync } = require('node:fs') const Diff = require('diff') const { moveRemove } = require('rimraf') const { sync: which } = require('which') diff --git a/test/fixtures/clean-snapshot.js b/test/fixtures/clean-snapshot.js index bd4ce1d01df93..bcbf699cb81fc 100644 --- a/test/fixtures/clean-snapshot.js +++ b/test/fixtures/clean-snapshot.js @@ -1,4 +1,4 @@ -const { relative, dirname } = require('path') +const { relative, dirname } = require('node:path') // normalize line endings (for ini) const cleanNewlines = (s) => s.replace(/\r\n/g, '\n') diff --git a/test/fixtures/mock-logs.js b/test/fixtures/mock-logs.js index a9277e4ce999c..3342b4e7614b2 100644 --- a/test/fixtures/mock-logs.js +++ b/test/fixtures/mock-logs.js @@ -1,5 +1,5 @@ const { log: { LEVELS } } = require('proc-log') -const { stripVTControlCharacters: stripAnsi } = require('util') +const { stripVTControlCharacters: stripAnsi } = require('node:util') const logPrefix = new RegExp(`^npm (${LEVELS.join('|')})\\s`) const isLog = (str) => logPrefix.test(stripAnsi(str)) diff --git a/test/fixtures/mock-npm.js b/test/fixtures/mock-npm.js index e1003e8da068a..9e9113972d6a3 100644 --- a/test/fixtures/mock-npm.js +++ b/test/fixtures/mock-npm.js @@ -1,7 +1,7 @@ -const os = require('os') -const fs = require('fs').promises -const fsSync = require('fs') -const path = require('path') +const os = require('node:os') +const fs = require('node:fs').promises +const fsSync = require('node:fs') +const path = require('node:path') const tap = require('tap') const mockLogs = require('./mock-logs.js') const mockGlobals = require('@npmcli/mock-globals') diff --git a/test/fixtures/tmock.js b/test/fixtures/tmock.js index 321e8bc07c581..ae270d57031bc 100644 --- a/test/fixtures/tmock.js +++ b/test/fixtures/tmock.js @@ -1,4 +1,4 @@ -const path = require('path') +const path = require('node:path') const ROOT = path.resolve(__dirname, '../..') const BIN = path.join(ROOT, 'bin') diff --git a/test/lib/arborist-cmd.js b/test/lib/arborist-cmd.js index dd90d47b9a000..6f848a650b83d 100644 --- a/test/lib/arborist-cmd.js +++ b/test/lib/arborist-cmd.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const { load: loadMockNpm } = require('../fixtures/mock-npm') const tmock = require('../fixtures/tmock') diff --git a/test/lib/cli/entry.js b/test/lib/cli/entry.js index 87563fab59902..900e3ab794317 100644 --- a/test/lib/cli/entry.js +++ b/test/lib/cli/entry.js @@ -1,6 +1,6 @@ const t = require('tap') -const { readdirSync } = require('fs') -const { dirname } = require('path') +const { readdirSync } = require('node:fs') +const { dirname } = require('node:path') const { load: loadMockNpm } = require('../../fixtures/mock-npm.js') const tmock = require('../../fixtures/tmock.js') const validateEngines = require('../../../lib/cli/validate-engines.js') diff --git a/test/lib/cli/update-notifier.js b/test/lib/cli/update-notifier.js index 2d29868b792a1..929e088bd4fa5 100644 --- a/test/lib/cli/update-notifier.js +++ b/test/lib/cli/update-notifier.js @@ -1,5 +1,5 @@ const t = require('tap') -const { basename } = require('path') +const { basename } = require('node:path') const tmock = require('../../fixtures/tmock') const mockNpm = require('../../fixtures/mock-npm') @@ -27,7 +27,7 @@ const runUpdateNotifier = async (t, { ...config } = {}) => { const mockFs = { - ...require('fs/promises'), + ...require('node:fs/promises'), stat: async (path) => { if (basename(path) !== '_update-notifier-last-checked') { t.fail('no stat allowed for non upate notifier files') @@ -69,7 +69,7 @@ const runUpdateNotifier = async (t, { const mocks = { pacote: mockPacote, - 'fs/promises': mockFs, + 'node:fs/promises': mockFs, '{ROOT}/package.json': { version }, 'ci-info': { isCI: false, name: null }, ..._mocks, diff --git a/test/lib/commands/adduser.js b/test/lib/commands/adduser.js index 3063cdbeeab5e..c69d996f91486 100644 --- a/test/lib/commands/adduser.js +++ b/test/lib/commands/adduser.js @@ -1,12 +1,12 @@ const t = require('tap') -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') const ini = require('ini') const { load: loadMockNpm } = require('../../fixtures/mock-npm.js') const mockGlobals = require('@npmcli/mock-globals') const MockRegistry = require('@npmcli/mock-registry') -const stream = require('stream') +const stream = require('node:stream') const mockAddUser = async (t, { stdin: stdinLines, registry: registryUrl, ...options } = {}) => { if (stdinLines) { diff --git a/test/lib/commands/audit.js b/test/lib/commands/audit.js index d8714cb61912a..4b239116188ca 100644 --- a/test/lib/commands/audit.js +++ b/test/lib/commands/audit.js @@ -1,6 +1,6 @@ -const fs = require('fs') -const zlib = require('zlib') -const path = require('path') +const fs = require('node:fs') +const zlib = require('node:zlib') +const path = require('node:path') const t = require('tap') const { default: tufmock } = require('@tufjs/repo-mock') diff --git a/test/lib/commands/cache.js b/test/lib/commands/cache.js index b962fa63f82a5..538a8c761a2d1 100644 --- a/test/lib/commands/cache.js +++ b/test/lib/commands/cache.js @@ -3,8 +3,8 @@ const { load: loadMockNpm } = require('../../fixtures/mock-npm.js') const MockRegistry = require('@npmcli/mock-registry') const cacache = require('cacache') -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') const pkg = 'test-package' diff --git a/test/lib/commands/ci.js b/test/lib/commands/ci.js index bcca4876fce79..8dc0f1d3cc149 100644 --- a/test/lib/commands/ci.js +++ b/test/lib/commands/ci.js @@ -1,5 +1,5 @@ -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') const t = require('tap') const { diff --git a/test/lib/commands/completion.js b/test/lib/commands/completion.js index 904d9410fdd6c..e9ed95929fc34 100644 --- a/test/lib/commands/completion.js +++ b/test/lib/commands/completion.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') const { load: loadMockNpm } = require('../../fixtures/mock-npm') const completionScript = fs diff --git a/test/lib/commands/config.js b/test/lib/commands/config.js index 1a3644a07623b..849f832554aab 100644 --- a/test/lib/commands/config.js +++ b/test/lib/commands/config.js @@ -1,5 +1,5 @@ -const { join } = require('path') -const fs = require('fs/promises') +const { join } = require('node:path') +const fs = require('node:fs/promises') const ini = require('ini') const tspawk = require('../../fixtures/tspawk') const t = require('tap') diff --git a/test/lib/commands/dedupe.js b/test/lib/commands/dedupe.js index 604ed21a257fc..c94b0b8228cea 100644 --- a/test/lib/commands/dedupe.js +++ b/test/lib/commands/dedupe.js @@ -1,6 +1,6 @@ const t = require('tap') -const path = require('path') -const fs = require('fs') +const path = require('node:path') +const fs = require('node:fs') const { load: loadMockNpm } = require('../../fixtures/mock-npm') const MockRegistry = require('@npmcli/mock-registry') diff --git a/test/lib/commands/diff.js b/test/lib/commands/diff.js index 36a9e4bc17d9f..3d55cd7879b7a 100644 --- a/test/lib/commands/diff.js +++ b/test/lib/commands/diff.js @@ -1,5 +1,5 @@ const t = require('tap') -const { join, extname } = require('path') +const { join, extname } = require('node:path') const MockRegistry = require('@npmcli/mock-registry') const { load: loadMockNpm } = require('../../fixtures/mock-npm') diff --git a/test/lib/commands/docs.js b/test/lib/commands/docs.js index 2a7951edeaf76..2dce707bf1a41 100644 --- a/test/lib/commands/docs.js +++ b/test/lib/commands/docs.js @@ -1,6 +1,6 @@ const t = require('tap') const mockNpm = require('../../fixtures/mock-npm.js') -const { sep } = require('path') +const { sep } = require('node:path') const fixtures = { pkg: { diff --git a/test/lib/commands/doctor.js b/test/lib/commands/doctor.js index 7dd53e10457d0..0c58a09e20c57 100644 --- a/test/lib/commands/doctor.js +++ b/test/lib/commands/doctor.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs/promises') -const path = require('path') +const fs = require('node:fs/promises') +const path = require('node:path') const { load: loadMockNpm } = require('../../fixtures/mock-npm') const tnock = require('../../fixtures/tnock.js') @@ -390,7 +390,7 @@ t.test('incorrect owner', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks: { ...mocks, - 'fs/promises': { + 'node:fs/promises': { ...fs, lstat: async (p) => { const stat = await fs.lstat(p) @@ -419,7 +419,7 @@ t.test('incorrect permissions', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks: { ...mocks, - 'fs/promises': { + 'node:fs/promises': { ...fs, access: async () => { throw new Error('Test Error') @@ -443,7 +443,7 @@ t.test('error reading directory', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks: { ...mocks, - 'fs/promises': { + 'node:fs/promises': { ...fs, readdir: async (s, ...args) => { if (s.endsWith('_logs')) { diff --git a/test/lib/commands/edit.js b/test/lib/commands/edit.js index 02621f1aef982..ae6826f7f98ad 100644 --- a/test/lib/commands/edit.js +++ b/test/lib/commands/edit.js @@ -1,5 +1,5 @@ const t = require('tap') -const path = require('path') +const path = require('node:path') const tspawk = require('../../fixtures/tspawk') const { load: loadMockNpm } = require('../../fixtures/mock-npm') diff --git a/test/lib/commands/exec.js b/test/lib/commands/exec.js index d0aa5f9a33974..c2977a2f577cb 100644 --- a/test/lib/commands/exec.js +++ b/test/lib/commands/exec.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs/promises') -const path = require('path') +const fs = require('node:fs/promises') +const path = require('node:path') const { load: loadMockNpm } = require('../../fixtures/mock-npm.js') const MockRegistry = require('@npmcli/mock-registry') diff --git a/test/lib/commands/explain.js b/test/lib/commands/explain.js index f4d898797bcbe..b55371c8b7e5c 100644 --- a/test/lib/commands/explain.js +++ b/test/lib/commands/explain.js @@ -1,5 +1,5 @@ const t = require('tap') -const { resolve } = require('path') +const { resolve } = require('node:path') const mockNpm = require('../../fixtures/mock-npm.js') const mockExplain = async (t, opts) => { diff --git a/test/lib/commands/find-dupes.js b/test/lib/commands/find-dupes.js index 40022fa065121..83dca6240b1c2 100644 --- a/test/lib/commands/find-dupes.js +++ b/test/lib/commands/find-dupes.js @@ -1,6 +1,6 @@ const t = require('tap') -const path = require('path') -const fs = require('fs') +const path = require('node:path') +const fs = require('node:fs') const { load: loadMockNpm } = require('../../fixtures/mock-npm') const MockRegistry = require('@npmcli/mock-registry') diff --git a/test/lib/commands/init.js b/test/lib/commands/init.js index 6dd23560bf8fa..f210c9bc2c931 100644 --- a/test/lib/commands/init.js +++ b/test/lib/commands/init.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs/promises') -const { resolve, basename } = require('path') +const fs = require('node:fs/promises') +const { resolve, basename } = require('node:path') const _mockNpm = require('../../fixtures/mock-npm') const { cleanTime } = require('../../fixtures/clean-snapshot') diff --git a/test/lib/commands/install.js b/test/lib/commands/install.js index 4fa234df99bea..0273f3deec73e 100644 --- a/test/lib/commands/install.js +++ b/test/lib/commands/install.js @@ -1,6 +1,6 @@ const tspawk = require('../../fixtures/tspawk') -const path = require('path') +const path = require('node:path') const t = require('tap') const { diff --git a/test/lib/commands/link.js b/test/lib/commands/link.js index 85bada28d67b1..184f7d6420339 100644 --- a/test/lib/commands/link.js +++ b/test/lib/commands/link.js @@ -1,6 +1,6 @@ const t = require('tap') -const { resolve, join } = require('path') -const fs = require('fs') +const { resolve, join } = require('node:path') +const fs = require('node:fs') const Arborist = require('@npmcli/arborist') const { cleanCwd } = require('../../fixtures/clean-snapshot.js') const mockNpm = require('../../fixtures/mock-npm') diff --git a/test/lib/commands/logout.js b/test/lib/commands/logout.js index 3087c8bb1e61d..840c92274bad0 100644 --- a/test/lib/commands/logout.js +++ b/test/lib/commands/logout.js @@ -1,8 +1,8 @@ const t = require('tap') -const fs = require('fs/promises') +const fs = require('node:fs/promises') const { load: loadMockNpm } = require('../../fixtures/mock-npm.js') const MockRegistry = require('@npmcli/mock-registry') -const { join } = require('path') +const { join } = require('node:path') t.test('token logout - user config', async t => { const { npm, home, logs } = await loadMockNpm(t, { diff --git a/test/lib/commands/ls.js b/test/lib/commands/ls.js index 9b773345525b5..2147b3f036d72 100644 --- a/test/lib/commands/ls.js +++ b/test/lib/commands/ls.js @@ -4,7 +4,7 @@ // may change when node-tap is updated. const t = require('tap') -const { utimesSync } = require('fs') +const { utimesSync } = require('node:fs') const mockNpm = require('../../fixtures/mock-npm.js') const { cleanCwd } = require('../../fixtures/clean-snapshot') @@ -100,7 +100,7 @@ const mockLs = async (t, { mocks, config, ...opts } = {}) => { command: 'ls', mocks: { path: { - ...require('path'), + ...require('node:path'), sep: '/', }, ...mocks, diff --git a/test/lib/commands/owner.js b/test/lib/commands/owner.js index ec774d1647048..e8b890a753eb1 100644 --- a/test/lib/commands/owner.js +++ b/test/lib/commands/owner.js @@ -2,7 +2,7 @@ const t = require('tap') const { load: loadMockNpm } = require('../../fixtures/mock-npm.js') const MockRegistry = require('@npmcli/mock-registry') -const path = require('path') +const path = require('node:path') const npa = require('npm-package-arg') const packageName = '@npmcli/test-package' const spec = npa(packageName) diff --git a/test/lib/commands/pack.js b/test/lib/commands/pack.js index fd525114cde9f..7e98b12704df9 100644 --- a/test/lib/commands/pack.js +++ b/test/lib/commands/pack.js @@ -1,8 +1,8 @@ const t = require('tap') const { load: loadMockNpm } = require('../../fixtures/mock-npm') const { cleanZlib } = require('../../fixtures/clean-snapshot') -const path = require('path') -const fs = require('fs') +const path = require('node:path') +const fs = require('node:fs') t.cleanSnapshot = data => cleanZlib(data) diff --git a/test/lib/commands/pkg.js b/test/lib/commands/pkg.js index 2941faf90c584..2306fe10db025 100644 --- a/test/lib/commands/pkg.js +++ b/test/lib/commands/pkg.js @@ -1,5 +1,5 @@ -const { resolve } = require('path') -const { readFileSync } = require('fs') +const { resolve } = require('node:path') +const { readFileSync } = require('node:fs') const t = require('tap') const _mockNpm = require('../../fixtures/mock-npm') const { cleanCwd } = require('../../fixtures/clean-snapshot') diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js index 9e7ba6b070583..a90d07d0ae572 100644 --- a/test/lib/commands/publish.js +++ b/test/lib/commands/publish.js @@ -4,8 +4,8 @@ const { cleanZlib } = require('../../fixtures/clean-snapshot') const MockRegistry = require('@npmcli/mock-registry') const pacote = require('pacote') const Arborist = require('@npmcli/arborist') -const path = require('path') -const fs = require('fs') +const path = require('node:path') +const fs = require('node:fs') const npa = require('npm-package-arg') const pkg = 'test-package' diff --git a/test/lib/commands/rebuild.js b/test/lib/commands/rebuild.js index bda161772ddfc..aa5578460b90f 100644 --- a/test/lib/commands/rebuild.js +++ b/test/lib/commands/rebuild.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs') -const { resolve } = require('path') +const fs = require('node:fs') +const { resolve } = require('node:path') const setupMockNpm = require('../../fixtures/mock-npm') t.test('no args', async t => { diff --git a/test/lib/commands/repo.js b/test/lib/commands/repo.js index f6e3ed753d039..1a8c9709ce133 100644 --- a/test/lib/commands/repo.js +++ b/test/lib/commands/repo.js @@ -1,6 +1,6 @@ const t = require('tap') const mockNpm = require('../../fixtures/mock-npm.js') -const { sep } = require('path') +const { sep } = require('node:path') const fixture = { 'package.json': JSON.stringify({ diff --git a/test/lib/commands/run-script.js b/test/lib/commands/run-script.js index 5009f13205747..6906a7de67d0b 100644 --- a/test/lib/commands/run-script.js +++ b/test/lib/commands/run-script.js @@ -1,5 +1,5 @@ const t = require('tap') -const { resolve } = require('path') +const { resolve } = require('node:path') const realRunScript = require('@npmcli/run-script') const mockNpm = require('../../fixtures/mock-npm') const { cleanCwd } = require('../../fixtures/clean-snapshot') diff --git a/test/lib/commands/sbom.js b/test/lib/commands/sbom.js index 3c79ed82cf837..25f6135ef8a14 100644 --- a/test/lib/commands/sbom.js +++ b/test/lib/commands/sbom.js @@ -70,8 +70,8 @@ const mockSbom = async (t, { mocks, config, ...opts } = {}) => { }, command: 'sbom', mocks: { - path: { - ...require('path'), + 'node:path': { + ...require('node:path'), sep: '/', }, ...mocks, diff --git a/test/lib/commands/set.js b/test/lib/commands/set.js index 69c4dd87056af..a4a2a7349ef1a 100644 --- a/test/lib/commands/set.js +++ b/test/lib/commands/set.js @@ -1,7 +1,7 @@ const t = require('tap') -const fs = require('fs/promises') +const fs = require('node:fs/promises') const mockNpm = require('../../fixtures/mock-npm') -const { join } = require('path') +const { join } = require('node:path') const { cleanNewlines } = require('../../fixtures/clean-snapshot') t.test('no args', async t => { diff --git a/test/lib/commands/shrinkwrap.js b/test/lib/commands/shrinkwrap.js index c5909a3ceaeac..ec65ca604a88b 100644 --- a/test/lib/commands/shrinkwrap.js +++ b/test/lib/commands/shrinkwrap.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs') -const { resolve } = require('path') +const fs = require('node:fs') +const { resolve } = require('node:path') const { load: loadMockNpm } = require('../../fixtures/mock-npm') // Attempt to parse json values in snapshots before diff --git a/test/lib/commands/uninstall.js b/test/lib/commands/uninstall.js index ae116d44c208b..a1ef1745d0f55 100644 --- a/test/lib/commands/uninstall.js +++ b/test/lib/commands/uninstall.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs') -const { resolve } = require('path') +const fs = require('node:fs') +const { resolve } = require('node:path') const _mockNpm = require('../../fixtures/mock-npm') const mockNpm = async (t, opts = {}) => { diff --git a/test/lib/commands/version.js b/test/lib/commands/version.js index 1f02f368f67bc..35987ed83cb7a 100644 --- a/test/lib/commands/version.js +++ b/test/lib/commands/version.js @@ -1,5 +1,5 @@ -const { readFileSync, statSync } = require('fs') -const { resolve } = require('path') +const { readFileSync, statSync } = require('node:fs') +const { resolve } = require('node:path') const t = require('tap') const _mockNpm = require('../../fixtures/mock-npm') const mockGlobals = require('@npmcli/mock-globals') diff --git a/test/lib/docs.js b/test/lib/docs.js index 67afd1b54d91e..833e58831ea51 100644 --- a/test/lib/docs.js +++ b/test/lib/docs.js @@ -1,6 +1,6 @@ const t = require('tap') -const { join, resolve, basename, extname } = require('path') -const fs = require('fs/promises') +const { join, resolve, basename, extname } = require('node:path') +const fs = require('node:fs/promises') const localeCompare = require('@isaacs/string-locale-compare')('en') const docs = require('@npmcli/docs') diff --git a/test/lib/load-all-commands.js b/test/lib/load-all-commands.js index c00da37eff3fc..892dd466ac5c4 100644 --- a/test/lib/load-all-commands.js +++ b/test/lib/load-all-commands.js @@ -3,7 +3,7 @@ // name, a description, and if it has completion it is a function. That it // renders also ensures that any params we've defined in our commands work. const t = require('tap') -const util = require('util') +const util = require('node:util') const { load: loadMockNpm } = require('../fixtures/mock-npm.js') const { commands } = require('../../lib/utils/cmd-list.js') const BaseCommand = require('../../lib/base-cmd.js') diff --git a/test/lib/npm.js b/test/lib/npm.js index a4f12f01c500a..00ef3f79b04c1 100644 --- a/test/lib/npm.js +++ b/test/lib/npm.js @@ -1,6 +1,6 @@ const t = require('tap') -const { resolve, dirname, join } = require('path') -const fs = require('fs') +const { resolve, dirname, join } = require('node:path') +const fs = require('node:fs') const { time } = require('proc-log') const { load: loadMockNpm } = require('../fixtures/mock-npm.js') const mockGlobals = require('@npmcli/mock-globals') diff --git a/test/lib/utils/display.js b/test/lib/utils/display.js index 33f9360e5728c..78bffa0221d03 100644 --- a/test/lib/utils/display.js +++ b/test/lib/utils/display.js @@ -3,7 +3,7 @@ const timers = require('node:timers/promises') const tmock = require('../../fixtures/tmock') const mockLogs = require('../../fixtures/mock-logs') const mockGlobals = require('@npmcli/mock-globals') -const { inspect } = require('util') +const { inspect } = require('node:util') const mockDisplay = async (t, { mocks, load } = {}) => { const procLog = require('proc-log') diff --git a/test/lib/utils/error-message.js b/test/lib/utils/error-message.js index c99971fd41233..1939e27c8ba92 100644 --- a/test/lib/utils/error-message.js +++ b/test/lib/utils/error-message.js @@ -1,6 +1,6 @@ const t = require('tap') -const { resolve } = require('path') -const fs = require('fs/promises') +const { resolve } = require('node:path') +const fs = require('node:fs/promises') const { load: _loadMockNpm } = require('../../fixtures/mock-npm.js') const mockGlobals = require('@npmcli/mock-globals') const tmock = require('../../fixtures/tmock') diff --git a/test/lib/utils/explain-dep.js b/test/lib/utils/explain-dep.js index 06174f36a7ffc..a90c0e90d5da6 100644 --- a/test/lib/utils/explain-dep.js +++ b/test/lib/utils/explain-dep.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const { explainNode, printNode } = require('../../../lib/utils/explain-dep.js') const { cleanCwd } = require('../../fixtures/clean-snapshot') diff --git a/test/lib/utils/get-workspaces.js b/test/lib/utils/get-workspaces.js index 931f90d13046f..1df21d885f278 100644 --- a/test/lib/utils/get-workspaces.js +++ b/test/lib/utils/get-workspaces.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const getWorkspaces = require('../../../lib/utils/get-workspaces.js') diff --git a/test/lib/utils/log-file.js b/test/lib/utils/log-file.js index 8e07da8671b6a..cb550b58c4fd0 100644 --- a/test/lib/utils/log-file.js +++ b/test/lib/utils/log-file.js @@ -1,8 +1,8 @@ const t = require('tap') -const _fs = require('fs') +const _fs = require('node:fs') const fs = _fs.promises -const path = require('path') -const os = require('os') +const path = require('node:path') +const os = require('node:os') const fsMiniPass = require('fs-minipass') const tmock = require('../../fixtures/tmock') const LogFile = require('../../../lib/utils/log-file.js') @@ -280,7 +280,7 @@ t.test('rimraf error', async t => { logsMax, testdir: makeOldLogs(oldLogs), mocks: { - 'fs/promises': { + 'node:fs/promises': { readdir: fs.readdir, rm: async (...args) => { if (count >= 3) { diff --git a/test/lib/utils/open-url.js b/test/lib/utils/open-url.js index ca52e8e32196b..096533140757e 100644 --- a/test/lib/utils/open-url.js +++ b/test/lib/utils/open-url.js @@ -1,7 +1,7 @@ const t = require('tap') const tmock = require('../../fixtures/tmock') const mockNpm = require('../../fixtures/mock-npm') -const EventEmitter = require('events') +const EventEmitter = require('node:events') const mockOpenUrl = async (t, args, { openerResult, ...config } = {}) => { let openerUrl = null diff --git a/test/lib/utils/queryable.js b/test/lib/utils/queryable.js index bde3ea66238f2..fb0db5d021b57 100644 --- a/test/lib/utils/queryable.js +++ b/test/lib/utils/queryable.js @@ -1,4 +1,4 @@ -const { inspect } = require('util') +const { inspect } = require('node:util') const t = require('tap') const Queryable = require('../../../lib/utils/queryable.js') diff --git a/test/lib/utils/reify-finish.js b/test/lib/utils/reify-finish.js index a2ca6e4367962..a1dd165034a46 100644 --- a/test/lib/utils/reify-finish.js +++ b/test/lib/utils/reify-finish.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs/promises') -const { join } = require('path') +const fs = require('node:fs/promises') +const { join } = require('node:path') const { cleanNewlines } = require('../../fixtures/clean-snapshot') const tmock = require('../../fixtures/tmock') const mockNpm = require('../../fixtures/mock-npm') diff --git a/test/lib/utils/timers.js b/test/lib/utils/timers.js index 4e5bfb104db97..f13b5ac2ba75d 100644 --- a/test/lib/utils/timers.js +++ b/test/lib/utils/timers.js @@ -1,5 +1,5 @@ const t = require('tap') -const { resolve, join } = require('path') +const { resolve, join } = require('node:path') const fs = require('graceful-fs') const { log, time } = require('proc-log') const tmock = require('../../fixtures/tmock') diff --git a/workspaces/arborist/bin/index.js b/workspaces/arborist/bin/index.js index 414c7eb468cd8..7c5d45f1f1fc9 100755 --- a/workspaces/arborist/bin/index.js +++ b/workspaces/arborist/bin/index.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') const { time } = require('proc-log') const { bin, arb: options } = require('./lib/options') diff --git a/workspaces/arborist/bin/lib/logging.js b/workspaces/arborist/bin/lib/logging.js index f06716735de74..431eea3ec404a 100644 --- a/workspaces/arborist/bin/lib/logging.js +++ b/workspaces/arborist/bin/lib/logging.js @@ -1,8 +1,8 @@ const { log } = require('proc-log') -const fs = require('fs') -const { dirname } = require('path') -const os = require('os') -const { inspect, format } = require('util') +const fs = require('node:fs') +const { dirname } = require('node:path') +const os = require('node:os') +const { inspect, format } = require('node:util') const { bin: options } = require('./options.js') diff --git a/workspaces/arborist/bin/lib/options.js b/workspaces/arborist/bin/lib/options.js index 8dbaf13dac03a..419c81850071b 100644 --- a/workspaces/arborist/bin/lib/options.js +++ b/workspaces/arborist/bin/lib/options.js @@ -1,5 +1,5 @@ const nopt = require('nopt') -const path = require('path') +const path = require('node:path') const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k) diff --git a/workspaces/arborist/bin/lib/print-tree.js b/workspaces/arborist/bin/lib/print-tree.js index 55398190b99cb..a110e6bcb8f03 100644 --- a/workspaces/arborist/bin/lib/print-tree.js +++ b/workspaces/arborist/bin/lib/print-tree.js @@ -1,4 +1,4 @@ -const { inspect } = require('util') +const { inspect } = require('node:util') const log = require('./logging.js') module.exports = tree => log.info(inspect(tree.toJSON(), { depth: Infinity })) diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js index 7808a4b0f86f1..06d03bbce7a32 100644 --- a/workspaces/arborist/lib/arborist/build-ideal-tree.js +++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js @@ -6,10 +6,10 @@ const pacote = require('pacote') const cacache = require('cacache') const { callLimit: promiseCallLimit } = require('promise-call-limit') const realpath = require('../../lib/realpath.js') -const { resolve, dirname } = require('path') +const { resolve, dirname } = require('node:path') const treeCheck = require('../tree-check.js') const { readdirScoped } = require('@npmcli/fs') -const { lstat, readlink } = require('fs/promises') +const { lstat, readlink } = require('node:fs/promises') const { depth } = require('treeverse') const { log, time } = require('proc-log') const { redact } = require('@npmcli/redact') diff --git a/workspaces/arborist/lib/arborist/index.js b/workspaces/arborist/lib/arborist/index.js index b348d490def65..3622f957b7acd 100644 --- a/workspaces/arborist/lib/arborist/index.js +++ b/workspaces/arborist/lib/arborist/index.js @@ -26,8 +26,8 @@ // the base class, so that the overall voltron class is easier to test and // cover, and separation of concerns can be maintained. -const { resolve } = require('path') -const { homedir } = require('os') +const { resolve } = require('node:path') +const { homedir } = require('node:os') const { depth } = require('treeverse') const mapWorkspaces = require('@npmcli/map-workspaces') const { log, time } = require('proc-log') @@ -47,7 +47,7 @@ const mixins = [ ] const _setWorkspaces = Symbol.for('setWorkspaces') -const Base = mixins.reduce((a, b) => b(a), require('events')) +const Base = mixins.reduce((a, b) => b(a), require('node:events')) // if it's 1, 2, or 3, set it explicitly that. // if undefined or null, set it null diff --git a/workspaces/arborist/lib/arborist/isolated-reifier.js b/workspaces/arborist/lib/arborist/isolated-reifier.js index 1e60d0f696b26..4fbcd801fdf63 100644 --- a/workspaces/arborist/lib/arborist/isolated-reifier.js +++ b/workspaces/arborist/lib/arborist/isolated-reifier.js @@ -1,11 +1,11 @@ const _makeIdealGraph = Symbol('makeIdealGraph') const _createIsolatedTree = Symbol.for('createIsolatedTree') const _createBundledTree = Symbol('createBundledTree') -const { mkdirSync } = require('fs') +const { mkdirSync } = require('node:fs') const pacote = require('pacote') -const { join } = require('path') +const { join } = require('node:path') const { depth } = require('treeverse') -const crypto = require('crypto') +const crypto = require('node:crypto') // cache complicated function results const memoize = (fn) => { diff --git a/workspaces/arborist/lib/arborist/load-actual.js b/workspaces/arborist/lib/arborist/load-actual.js index 81c1bd1132775..22c1c2875f1b1 100644 --- a/workspaces/arborist/lib/arborist/load-actual.js +++ b/workspaces/arborist/lib/arborist/load-actual.js @@ -1,6 +1,6 @@ // mix-in implementing the loadActual method -const { relative, dirname, resolve, join, normalize } = require('path') +const { relative, dirname, resolve, join, normalize } = require('node:path') const rpj = require('read-package-json-fast') const { readdirScoped } = require('@npmcli/fs') diff --git a/workspaces/arborist/lib/arborist/load-virtual.js b/workspaces/arborist/lib/arborist/load-virtual.js index d96d4adc88a70..7c51f8b9bef79 100644 --- a/workspaces/arborist/lib/arborist/load-virtual.js +++ b/workspaces/arborist/lib/arborist/load-virtual.js @@ -1,7 +1,7 @@ // mixin providing the loadVirtual method const mapWorkspaces = require('@npmcli/map-workspaces') -const { resolve } = require('path') +const { resolve } = require('node:path') const nameFromFolder = require('@npmcli/name-from-folder') const consistentResolve = require('../consistent-resolve.js') diff --git a/workspaces/arborist/lib/arborist/rebuild.js b/workspaces/arborist/lib/arborist/rebuild.js index 4f8730cde7f38..82f84772f9a85 100644 --- a/workspaces/arborist/lib/arborist/rebuild.js +++ b/workspaces/arborist/lib/arborist/rebuild.js @@ -8,7 +8,7 @@ const rpj = require('read-package-json-fast') const binLinks = require('bin-links') const runScript = require('@npmcli/run-script') const { callLimit: promiseCallLimit } = require('promise-call-limit') -const { resolve } = require('path') +const { resolve } = require('node:path') const { isNodeGypPackage, defaultGypInstallScript } = require('@npmcli/node-gyp') const { log, time } = require('proc-log') diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 96704f6556e0d..be920272d48f0 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -11,14 +11,14 @@ const { log, time } = require('proc-log') const hgi = require('hosted-git-info') const rpj = require('read-package-json-fast') -const { dirname, resolve, relative, join } = require('path') +const { dirname, resolve, relative, join } = require('node:path') const { depth: dfwalk } = require('treeverse') const { lstat, mkdir, rm, symlink, -} = require('fs/promises') +} = require('node:fs/promises') const { moveFile } = require('@npmcli/fs') const PackageJson = require('@npmcli/package-json') const packageContents = require('@npmcli/installed-package-contents') diff --git a/workspaces/arborist/lib/debug.js b/workspaces/arborist/lib/debug.js index aeda7229d5e8c..81fd34353c378 100644 --- a/workspaces/arborist/lib/debug.js +++ b/workspaces/arborist/lib/debug.js @@ -18,13 +18,13 @@ const debug = process.env.ARBORIST_DEBUG !== '0' && ( /\barborist\b/.test(process.env.NODE_DEBUG || '') || process.env.npm_package_name === '@npmcli/arborist' && ['test', 'snap'].includes(process.env.npm_lifecycle_event) || - process.cwd() === require('path').resolve(__dirname, '..') + process.cwd() === require('node:path').resolve(__dirname, '..') ) module.exports = debug ? fn => fn() : () => {} const red = process.stderr.isTTY ? msg => `\x1B[31m${msg}\x1B[39m` : m => m module.exports.log = (...msg) => module.exports(() => { - const { format } = require('util') + const { format } = require('node:util') const prefix = `\n${process.pid} ${red(format(msg.shift()))} ` msg = (prefix + format(...msg).trim().split('\n').join(prefix)).trim() console.error(msg) diff --git a/workspaces/arborist/lib/dep-valid.js b/workspaces/arborist/lib/dep-valid.js index 58656e8dbbad2..e80310d9663a9 100644 --- a/workspaces/arborist/lib/dep-valid.js +++ b/workspaces/arborist/lib/dep-valid.js @@ -6,7 +6,7 @@ const semver = require('semver') const npa = require('npm-package-arg') -const { relative } = require('path') +const { relative } = require('node:path') const fromPath = require('./from-path.js') const depValid = (child, requested, requestor) => { diff --git a/workspaces/arborist/lib/diff.js b/workspaces/arborist/lib/diff.js index 0387773c29754..fb94407bb0166 100644 --- a/workspaces/arborist/lib/diff.js +++ b/workspaces/arborist/lib/diff.js @@ -6,7 +6,7 @@ // for a given branch of the tree being mutated. const { depth } = require('treeverse') -const { existsSync } = require('fs') +const { existsSync } = require('node:fs') const ssri = require('ssri') diff --git a/workspaces/arborist/lib/edge.js b/workspaces/arborist/lib/edge.js index cc9698ad6cae7..77ba196e68eeb 100644 --- a/workspaces/arborist/lib/edge.js +++ b/workspaces/arborist/lib/edge.js @@ -1,7 +1,7 @@ // An edge in the dependency graph // Represents a dependency relationship of some kind -const util = require('util') +const util = require('node:util') const npa = require('npm-package-arg') const depValid = require('./dep-valid.js') diff --git a/workspaces/arborist/lib/from-path.js b/workspaces/arborist/lib/from-path.js index 761f15125b343..f7e447495d144 100644 --- a/workspaces/arborist/lib/from-path.js +++ b/workspaces/arborist/lib/from-path.js @@ -3,7 +3,7 @@ // installed. directory (ie, symlink) deps also need to be resolved based on // their targets, but that's what realpath is -const { dirname } = require('path') +const { dirname } = require('node:path') const npa = require('npm-package-arg') const fromPath = (node, edge) => { diff --git a/workspaces/arborist/lib/link.js b/workspaces/arborist/lib/link.js index 197f96c5c2ddb..266ec45168839 100644 --- a/workspaces/arborist/lib/link.js +++ b/workspaces/arborist/lib/link.js @@ -2,7 +2,7 @@ const relpath = require('./relpath.js') const Node = require('./node.js') const _loadDeps = Symbol.for('Arborist.Node._loadDeps') const _target = Symbol.for('_target') -const { dirname } = require('path') +const { dirname } = require('node:path') // defined by Node class const _delistFromMeta = Symbol.for('_delistFromMeta') const _refreshLocation = Symbol.for('_refreshLocation') diff --git a/workspaces/arborist/lib/node.js b/workspaces/arborist/lib/node.js index d5c5a478cce0b..c519a7b543d4d 100644 --- a/workspaces/arborist/lib/node.js +++ b/workspaces/arborist/lib/node.js @@ -41,8 +41,8 @@ const gatherDepSet = require('./gather-dep-set.js') const treeCheck = require('./tree-check.js') const { walkUp } = require('walk-up-path') -const { resolve, relative, dirname, basename } = require('path') -const util = require('util') +const { resolve, relative, dirname, basename } = require('node:path') +const util = require('node:util') const _package = Symbol('_package') const _parent = Symbol('_parent') const _target = Symbol.for('_target') diff --git a/workspaces/arborist/lib/printable.js b/workspaces/arborist/lib/printable.js index 7c8d52a4207aa..53c3f7a5756df 100644 --- a/workspaces/arborist/lib/printable.js +++ b/workspaces/arborist/lib/printable.js @@ -1,7 +1,7 @@ // helper function to output a clearer visualization // of the current node and its descendents const localeCompare = require('@isaacs/string-locale-compare')('en') -const util = require('util') +const util = require('node:util') const relpath = require('./relpath.js') class ArboristNode { diff --git a/workspaces/arborist/lib/query-selector-all.js b/workspaces/arborist/lib/query-selector-all.js index 77640a3803d13..fa48d5f84b556 100644 --- a/workspaces/arborist/lib/query-selector-all.js +++ b/workspaces/arborist/lib/query-selector-all.js @@ -1,6 +1,6 @@ 'use strict' -const { resolve } = require('path') +const { resolve } = require('node:path') const { parser, arrayDelimiter } = require('@npmcli/query') const localeCompare = require('@isaacs/string-locale-compare')('en') const { log } = require('proc-log') diff --git a/workspaces/arborist/lib/realpath.js b/workspaces/arborist/lib/realpath.js index 8dc20ab63d836..6e5ad9b77ba5a 100644 --- a/workspaces/arborist/lib/realpath.js +++ b/workspaces/arborist/lib/realpath.js @@ -5,8 +5,8 @@ // built-in fs.realpath, because we only care about symbolic links, // so we can handle many fewer edge cases. -const { lstat, readlink } = require('fs/promises') -const { resolve, basename, dirname } = require('path') +const { lstat, readlink } = require('node:fs/promises') +const { resolve, basename, dirname } = require('node:path') const realpathCached = (path, rpcache, stcache, depth) => { // just a safety against extremely deep eloops diff --git a/workspaces/arborist/lib/relpath.js b/workspaces/arborist/lib/relpath.js index e1960cfec02c7..a4187b5f6095f 100644 --- a/workspaces/arborist/lib/relpath.js +++ b/workspaces/arborist/lib/relpath.js @@ -1,3 +1,3 @@ -const { relative } = require('path') +const { relative } = require('node:path') const relpath = (from, to) => relative(from, to).replace(/\\/g, '/') module.exports = relpath diff --git a/workspaces/arborist/lib/retire-path.js b/workspaces/arborist/lib/retire-path.js index 0c7a4a319e279..5bff79a15a165 100644 --- a/workspaces/arborist/lib/retire-path.js +++ b/workspaces/arborist/lib/retire-path.js @@ -1,5 +1,5 @@ -const crypto = require('crypto') -const { dirname, basename, resolve } = require('path') +const crypto = require('node:crypto') +const { dirname, basename, resolve } = require('node:path') // use sha1 because it's faster, and collisions extremely unlikely anyway const pathSafeHash = s => diff --git a/workspaces/arborist/lib/shrinkwrap.js b/workspaces/arborist/lib/shrinkwrap.js index 111c73889c876..6f6c17cb95374 100644 --- a/workspaces/arborist/lib/shrinkwrap.js +++ b/workspaces/arborist/lib/shrinkwrap.js @@ -42,9 +42,9 @@ const { rm, stat, writeFile, -} = require('fs/promises') +} = require('node:fs/promises') -const { resolve, basename, relative } = require('path') +const { resolve, basename, relative } = require('node:path') const specFromLock = require('./spec-from-lock.js') const versionFromTgz = require('./version-from-tgz.js') const npa = require('npm-package-arg') diff --git a/workspaces/arborist/lib/version-from-tgz.js b/workspaces/arborist/lib/version-from-tgz.js index 092cdbcbaf132..77e3956c1c171 100644 --- a/workspaces/arborist/lib/version-from-tgz.js +++ b/workspaces/arborist/lib/version-from-tgz.js @@ -1,6 +1,6 @@ const semver = require('semver') -const { basename } = require('path') -const { URL } = require('url') +const { basename } = require('node:path') +const { URL } = require('node:url') module.exports = (name, tgz) => { const base = basename(tgz) if (!base.endsWith('.tgz')) { diff --git a/workspaces/arborist/lib/yarn-lock.js b/workspaces/arborist/lib/yarn-lock.js index d5693a3eff943..fc62806506acd 100644 --- a/workspaces/arborist/lib/yarn-lock.js +++ b/workspaces/arborist/lib/yarn-lock.js @@ -29,7 +29,7 @@ const localeCompare = require('@isaacs/string-locale-compare')('en') const consistentResolve = require('./consistent-resolve.js') -const { dirname } = require('path') +const { dirname } = require('node:path') const { breadth } = require('treeverse') // Sort Yarn entries respecting the yarn.lock sort order diff --git a/workspaces/arborist/scripts/benchmark.js b/workspaces/arborist/scripts/benchmark.js index 21f5432de76f6..355f3f48b4cb4 100644 --- a/workspaces/arborist/scripts/benchmark.js +++ b/workspaces/arborist/scripts/benchmark.js @@ -1,10 +1,10 @@ process.env.ARBORIST_DEBUG = '0' const { Suite } = require('benchmark') -const { relative, resolve } = require('path') -const { mkdir, rm } = require('fs/promises') -const { execSync } = require('child_process') -const { linkSync, writeFileSync, readdirSync } = require('fs') +const { relative, resolve } = require('node:path') +const { mkdir, rm } = require('node:fs/promises') +const { execSync } = require('node:child_process') +const { linkSync, writeFileSync, readdirSync } = require('node:fs') const registryServer = require('../test/fixtures/server.js') const shaCmd = 'git show --no-patch --pretty=%H HEAD' diff --git a/workspaces/arborist/scripts/benchmark/load-actual.js b/workspaces/arborist/scripts/benchmark/load-actual.js index ddc8145bcb60d..5c51dec88705d 100644 --- a/workspaces/arborist/scripts/benchmark/load-actual.js +++ b/workspaces/arborist/scripts/benchmark/load-actual.js @@ -1,7 +1,7 @@ const Arborist = require('../..') -const { resolve, basename } = require('path') -const { writeFileSync } = require('fs') -const { mkdir, rm } = require('fs/promises') +const { resolve, basename } = require('node:path') +const { writeFileSync } = require('node:fs') +const { mkdir, rm } = require('node:fs/promises') const dir = resolve(__dirname, basename(__filename, '.js')) diff --git a/workspaces/arborist/scripts/benchmark/reify.js b/workspaces/arborist/scripts/benchmark/reify.js index 797a5cb803682..0dec49c363356 100644 --- a/workspaces/arborist/scripts/benchmark/reify.js +++ b/workspaces/arborist/scripts/benchmark/reify.js @@ -1,7 +1,7 @@ const Arborist = require('../..') -const { resolve, basename } = require('path') -const { writeFileSync, rmSync } = require('fs') -const { mkdir } = require('fs/promises') +const { resolve, basename } = require('node:path') +const { writeFileSync, rmSync } = require('node:fs') +const { mkdir } = require('node:fs/promises') const dir = resolve(__dirname, basename(__filename, '.js')) // these are not arbitrary, the empty/full and no-* bits matter diff --git a/workspaces/arborist/test/arborist/audit.js b/workspaces/arborist/test/arborist/audit.js index bf301eb62d11f..11205899057a3 100644 --- a/workspaces/arborist/test/arborist/audit.js +++ b/workspaces/arborist/test/arborist/audit.js @@ -1,5 +1,5 @@ const t = require('tap') -const { resolve } = require('path') +const { resolve } = require('node:path') const Arborist = require('../../lib/arborist/index.js') const { normalizePath, printTree } = require('../fixtures/utils.js') const { auditResponse, advisoryBulkResponse, ...mockRegistry } = require('../fixtures/server.js') diff --git a/workspaces/arborist/test/arborist/build-ideal-tree.js b/workspaces/arborist/test/arborist/build-ideal-tree.js index 1b9940c5ae05a..807287c73cf11 100644 --- a/workspaces/arborist/test/arborist/build-ideal-tree.js +++ b/workspaces/arborist/test/arborist/build-ideal-tree.js @@ -4,7 +4,7 @@ if (process.platform === 'win32') { process.env.ARBORIST_DEBUG = 0 } -const { basename, resolve, relative } = require('path') +const { basename, resolve, relative } = require('node:path') const pacote = require('pacote') const t = require('tap') const Arborist = require('../..') @@ -13,7 +13,7 @@ const fixtures = resolve(__dirname, '../fixtures') require(fixtures) const { start, stop, registry, auditResponse } = require('../fixtures/server.js') const npa = require('npm-package-arg') -const fs = require('fs') +const fs = require('node:fs') const nock = require('nock') const semver = require('semver') diff --git a/workspaces/arborist/test/arborist/index.js b/workspaces/arborist/test/arborist/index.js index 88da04b94ffed..eb4b2c760d80b 100644 --- a/workspaces/arborist/test/arborist/index.js +++ b/workspaces/arborist/test/arborist/index.js @@ -27,7 +27,7 @@ t.throws(() => { }, /saveType/, 'rejects invalid saveType') t.test('workspace nodes and deps', async t => { - const { resolve } = require('path') + const { resolve } = require('node:path') const fixture = resolve(__dirname, '../fixtures/workspaces-shared-deps-virtual') const arb = new Arborist({ path: fixture }) const tree = await arb.loadVirtual() diff --git a/workspaces/arborist/test/arborist/load-actual-ctor-throw.js b/workspaces/arborist/test/arborist/load-actual-ctor-throw.js index 63d859b76e0ea..82569f1311cfa 100644 --- a/workspaces/arborist/test/arborist/load-actual-ctor-throw.js +++ b/workspaces/arborist/test/arborist/load-actual-ctor-throw.js @@ -10,7 +10,7 @@ const Arborist = t.mock('../../lib/arborist', { 'read-package-json-fast': rpjMock, }) -const { resolve } = require('path') +const { resolve } = require('node:path') const { fixtures } = require('../fixtures/index.js') t.test('blow up and catch error if Node ctor blows up', t => { diff --git a/workspaces/arborist/test/arborist/load-actual.js b/workspaces/arborist/test/arborist/load-actual.js index 9c2c8bf1cd4b8..11f2a8cf15ace 100644 --- a/workspaces/arborist/test/arborist/load-actual.js +++ b/workspaces/arborist/test/arborist/load-actual.js @@ -2,10 +2,10 @@ const t = require('tap') const { format } = require('tcompare') const Arborist = require('../../lib/arborist') -const { resolve } = require('path') +const { resolve } = require('node:path') const Node = require('../../lib/node.js') const Shrinkwrap = require('../../lib/shrinkwrap.js') -const fs = require('fs') +const fs = require('node:fs') const { fixtures, diff --git a/workspaces/arborist/test/arborist/load-virtual.js b/workspaces/arborist/test/arborist/load-virtual.js index ff6dd26ccdea3..3b50444c851ae 100644 --- a/workspaces/arborist/test/arborist/load-virtual.js +++ b/workspaces/arborist/test/arborist/load-virtual.js @@ -1,6 +1,6 @@ const Arborist = require('../../lib/arborist') const t = require('tap') -const { resolve } = require('path') +const { resolve } = require('node:path') const fixture = resolve(__dirname, '../fixtures/install-types') const swonlyfixture = resolve(__dirname, '../fixtures/install-types-sw-only') const badfixture = resolve(__dirname, '../fixtures/root') diff --git a/workspaces/arborist/test/arborist/pruner.js b/workspaces/arborist/test/arborist/pruner.js index 9be29442acdea..7c4bec0c5e2ed 100644 --- a/workspaces/arborist/test/arborist/pruner.js +++ b/workspaces/arborist/test/arborist/pruner.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const Arborist = require('../../lib/arborist/index.js') @@ -80,8 +80,8 @@ t.test('prune with lockfile omit dev', async t => { }) t.test('prune omit dev with bins', async t => { - const { readdir } = require('fs/promises') - const { statSync, lstatSync } = require('fs') + const { readdir } = require('node:fs/promises') + const { statSync, lstatSync } = require('node:fs') const path = fixture(t, 'prune-dev-bins') // should have bin files @@ -113,8 +113,8 @@ t.test('prune omit dev with bins', async t => { }) t.test('prune workspaces', async t => { - const fs = require('fs') - const { join } = require('path') + const fs = require('node:fs') + const { join } = require('node:path') const path = t.testdir({ 'package.json': JSON.stringify({ name: 'prune-workspaces', diff --git a/workspaces/arborist/test/arborist/rebuild.js b/workspaces/arborist/test/arborist/rebuild.js index 7cf6c381197d2..b53b7309a4870 100644 --- a/workspaces/arborist/test/arborist/rebuild.js +++ b/workspaces/arborist/test/arborist/rebuild.js @@ -1,9 +1,9 @@ const t = require('tap') const _trashList = Symbol.for('trashList') const Arborist = require('../../lib/arborist/index.js') -const { resolve, dirname } = require('path') -const os = require('os') -const fs = require('fs') +const { resolve, dirname } = require('node:path') +const os = require('node:os') +const fs = require('node:fs') const fixtures = resolve(__dirname, '../fixtures') const relpath = require('../../lib/relpath.js') const localeCompare = require('@isaacs/string-locale-compare')('en') @@ -13,7 +13,7 @@ const fixture = (t, p) => require(`${fixtures}/reify-cases/${p}`)(t) const isWindows = process.platform === 'win32' const PORT = 12345 + (+process.env.TAP_CHILD_ID || 0) -const server = require('http').createServer(() => { +const server = require('node:http').createServer(() => { throw new Error('rebuild should not hit the registry') }) t.before(() => new Promise(res => { diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 7600f2dabad8d..0a7fb416040c0 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -1,47 +1,17 @@ -const { join, resolve, basename } = require('path') +const { join, resolve, basename } = require('node:path') const t = require('tap') const runScript = require('@npmcli/run-script') const localeCompare = require('@isaacs/string-locale-compare')('en') const tnock = require('../fixtures/tnock') -const fs = require('fs') -const fsp = require('fs/promises') +const fs = require('node:fs') +const fsp = require('node:fs/promises') const npmFs = require('@npmcli/fs') let failRm = false let failRename = null let failRenameOnce = null let failMkdir = null -const { rename: realRename, rm: realRm, mkdir: realMkdir } = fs -const fsMock = { - ...fs, - mkdir (...args) { - if (failMkdir) { - process.nextTick(() => args.pop()(failMkdir)) - return - } - - return realMkdir(...args) - }, - rename (...args) { - if (failRename) { - process.nextTick(() => args.pop()(failRename)) - } else if (failRenameOnce) { - const er = failRenameOnce - failRenameOnce = null - process.nextTick(() => args.pop()(er)) - } else { - return realRename(...args) - } - }, - rm (...args) { - if (failRm) { - process.nextTick(() => args.pop()(new Error('rm fail'))) - return - } - realRm(...args) - }, -} const fspMock = { ...fsp, mkdir: async (...args) => { @@ -70,11 +40,11 @@ const fspMock = { return fsp.rm(...args) }, } + // need this to be injected so that it doesn't pull from main cache const { moveFile } = t.mock('@npmcli/fs', { 'fs/promises': fspMock }) const mocks = { - fs: fsMock, - 'fs/promises': fspMock, + 'node:fs/promises': fspMock, '@npmcli/fs': { ...npmFs, moveFile }, } @@ -1503,7 +1473,7 @@ t.test('rollback if process is terminated during reify process', async t => { const onExit = require('../../lib/signal-handling.js') // mock the process so we don't have to kill this test // copy-pasta from signal-handling test - const EE = require('events') + const EE = require('node:events') const proc = onExit.process = new class MockProcess extends EE { constructor () { super() diff --git a/workspaces/arborist/test/arborist/validate-path.js b/workspaces/arborist/test/arborist/validate-path.js index e5155d27d4e41..9ab75402b0282 100644 --- a/workspaces/arborist/test/arborist/validate-path.js +++ b/workspaces/arborist/test/arborist/validate-path.js @@ -20,7 +20,7 @@ process.env.__TESTING_MKDIRP_INFER_OWNER_PLATFORM__ = 'posix' const Arborist = t.mock('../../lib/arborist/index.js', { chownr }) -const { resolve } = require('path') +const { resolve } = require('node:path') t.test('reify a folder that does not exist', async t => { const path = resolve(t.testdir({}), 'does-not-exist-yet') const arb = new Arborist({ path }) diff --git a/workspaces/arborist/test/audit-report.js b/workspaces/arborist/test/audit-report.js index 18751b9cd96a5..6f4bcf8858f35 100644 --- a/workspaces/arborist/test/audit-report.js +++ b/workspaces/arborist/test/audit-report.js @@ -16,7 +16,7 @@ const { t.before(start) t.teardown(stop) -const { resolve } = require('path') +const { resolve } = require('node:path') const fixtures = resolve(__dirname, 'fixtures') const cache = t.testdir() diff --git a/workspaces/arborist/test/calc-dep-flags.js b/workspaces/arborist/test/calc-dep-flags.js index 7e6d0679fba35..bba64fc5dd0dc 100644 --- a/workspaces/arborist/test/calc-dep-flags.js +++ b/workspaces/arborist/test/calc-dep-flags.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const calcDepFlags = require('../lib/calc-dep-flags.js') const Node = require('../lib/node.js') diff --git a/workspaces/arborist/test/debug.js b/workspaces/arborist/test/debug.js index 26b4b5ffc0976..99a94812fba89 100644 --- a/workspaces/arborist/test/debug.js +++ b/workspaces/arborist/test/debug.js @@ -1,5 +1,5 @@ const t = require('tap') -const { resolve } = require('path') +const { resolve } = require('node:path') // start from clean slate delete process.env.ARBORIST_DEBUG diff --git a/workspaces/arborist/test/dep-valid.js b/workspaces/arborist/test/dep-valid.js index aaf7da0b5864f..ce6af25243c6c 100644 --- a/workspaces/arborist/test/dep-valid.js +++ b/workspaces/arborist/test/dep-valid.js @@ -2,7 +2,7 @@ const t = require('tap') const depValid = require('../lib/dep-valid.js') const npa = require('npm-package-arg') const { normalizePaths } = require('./fixtures/utils.js') -const { resolve } = require('path') +const { resolve } = require('node:path') // dep-valid reads from requestor.edgesOut so we use this instead of {} in these tests const emptyRequestor = { diff --git a/workspaces/arborist/test/edge.js b/workspaces/arborist/test/edge.js index ab08357ece359..bb8977897fcc0 100644 --- a/workspaces/arborist/test/edge.js +++ b/workspaces/arborist/test/edge.js @@ -1,4 +1,4 @@ -const util = require('util') +const util = require('node:util') const Edge = require('../lib/edge.js') const OverrideSet = require('../lib/override-set.js') const t = require('tap') diff --git a/workspaces/arborist/test/fixtures/cleanup.js b/workspaces/arborist/test/fixtures/cleanup.js index 2758b7222433f..911a9cd8dd092 100644 --- a/workspaces/arborist/test/fixtures/cleanup.js +++ b/workspaces/arborist/test/fixtures/cleanup.js @@ -1,5 +1,5 @@ -const { resolve } = require('path') -const { readdirSync, lstatSync } = require('fs') +const { resolve } = require('node:path') +const { readdirSync, lstatSync } = require('node:fs') process.env.ARBORIST_FIXTURE_CLEANUP = '1' require('./index.js') diff --git a/workspaces/arborist/test/fixtures/create-reify-case.js b/workspaces/arborist/test/fixtures/create-reify-case.js index a0b8e8eb6cf1f..5d2349dd33076 100644 --- a/workspaces/arborist/test/fixtures/create-reify-case.js +++ b/workspaces/arborist/test/fixtures/create-reify-case.js @@ -8,9 +8,9 @@ const { readFileSync, readlinkSync, writeFileSync, -} = require('fs') +} = require('node:fs') -const { resolve, relative, basename } = require('path') +const { resolve, relative, basename } = require('node:path') if (!process.argv[2]) { console.error('pass in a folder as an argument') @@ -27,7 +27,7 @@ const symlinks = new Map() const jsonFiles = new Map() const longFiles = new Map() const buffers = new Map() -const crypto = require('crypto') +const crypto = require('node:crypto') const token = p => p + crypto.randomBytes(8).toString('base64') const hiddenLocks = [] diff --git a/workspaces/arborist/test/fixtures/fetch-lock-contents.js b/workspaces/arborist/test/fixtures/fetch-lock-contents.js index a192c35c7585b..fccb55fffdf67 100644 --- a/workspaces/arborist/test/fixtures/fetch-lock-contents.js +++ b/workspaces/arborist/test/fixtures/fetch-lock-contents.js @@ -1,8 +1,8 @@ // fetch all the deps and tarballs in a v2 lockfile const pacote = require('pacote') -const url = require('url') -const { dirname, resolve } = require('path') -const fs = require('fs/promises') +const url = require('node:url') +const { dirname, resolve } = require('node:path') +const fs = require('node:fs/promises') const Arborist = require('./index.js') const dir = resolve(__dirname, 'registry-mocks', 'content') diff --git a/workspaces/arborist/test/fixtures/index.js b/workspaces/arborist/test/fixtures/index.js index 2317d3f4b0515..1ec9159a2b598 100644 --- a/workspaces/arborist/test/fixtures/index.js +++ b/workspaces/arborist/test/fixtures/index.js @@ -1,7 +1,7 @@ -const { mkdirSync } = require('fs') +const { mkdirSync } = require('node:fs') const localeCompare = require('@isaacs/string-locale-compare')('en') -const { unlinkSync, symlinkSync, readFileSync, writeFileSync } = require('fs') -const { relative, resolve, dirname } = require('path') +const { unlinkSync, symlinkSync, readFileSync, writeFileSync } = require('node:fs') +const { relative, resolve, dirname } = require('node:path') const mkdirp = (p) => mkdirSync(p, { recursive: true }) const fixtures = __dirname diff --git a/workspaces/arborist/test/fixtures/isolated-nock.js b/workspaces/arborist/test/fixtures/isolated-nock.js index 5086d3931923c..6593c7f0d1935 100644 --- a/workspaces/arborist/test/fixtures/isolated-nock.js +++ b/workspaces/arborist/test/fixtures/isolated-nock.js @@ -1,9 +1,9 @@ const nock = require('nock') const tar = require('tar-stream') -const Stream = require('stream') -const fs = require('fs') -const path = require('path') -const os = require('os') +const Stream = require('node:stream') +const fs = require('node:fs') +const path = require('node:path') +const os = require('node:os') /* Utility to extract a buffer out of a stream */ class StreamToBuffer extends Stream.Writable { diff --git a/workspaces/arborist/test/fixtures/server.js b/workspaces/arborist/test/fixtures/server.js index 450cadf32a959..61962b16c09be 100644 --- a/workspaces/arborist/test/fixtures/server.js +++ b/workspaces/arborist/test/fixtures/server.js @@ -1,9 +1,9 @@ -const { join, dirname } = require('path') -const { promisify } = require('util') -const fs = require('fs/promises') -const http = require('http') -const https = require('https') -const zlib = require('zlib') +const { join, dirname } = require('node:path') +const { promisify } = require('node:util') +const fs = require('node:fs/promises') +const http = require('node:http') +const https = require('node:https') +const zlib = require('node:zlib') const mrm = require('minify-registry-metadata') const gzip = promisify(zlib.gzip) diff --git a/workspaces/arborist/test/get-workspace-nodes.js b/workspaces/arborist/test/get-workspace-nodes.js index 851b12061cdef..78d6790a09730 100644 --- a/workspaces/arborist/test/get-workspace-nodes.js +++ b/workspaces/arborist/test/get-workspace-nodes.js @@ -1,6 +1,6 @@ const t = require('tap') const Arborist = require('../lib/arborist/index.js') -const { resolve } = require('path') +const { resolve } = require('node:path') const path = resolve(__dirname, './fixtures/workspaces-shared-deps-virtual') const arb = new Arborist({ path }) diff --git a/workspaces/arborist/test/isolated-mode.js b/workspaces/arborist/test/isolated-mode.js index 044d44a4dd2ad..dcc293b82dc77 100644 --- a/workspaces/arborist/test/isolated-mode.js +++ b/workspaces/arborist/test/isolated-mode.js @@ -1,7 +1,7 @@ const tap = require('tap') -const fs = require('fs') -const path = require('path') -const os = require('os') +const fs = require('node:fs') +const path = require('node:path') +const os = require('node:os') const oldMap = Map diff --git a/workspaces/arborist/test/link.js b/workspaces/arborist/test/link.js index ec648eda256d4..685ace11046d3 100644 --- a/workspaces/arborist/test/link.js +++ b/workspaces/arborist/test/link.js @@ -6,7 +6,7 @@ const Link = require('../lib/link.js') const Node = require('../lib/node.js') const Shrinkwrap = require('../lib/shrinkwrap.js') -const { resolve } = require('path') +const { resolve } = require('node:path') const normalizePath = path => path.replace(/^[A-Z]:/, '').replace(/\\/g, '/') const normalizePaths = obj => { obj.path = obj.path && normalizePath(obj.path) diff --git a/workspaces/arborist/test/node.js b/workspaces/arborist/test/node.js index 347a55209644f..f5090dc2def5a 100644 --- a/workspaces/arborist/test/node.js +++ b/workspaces/arborist/test/node.js @@ -1,10 +1,10 @@ -const util = require('util') +const util = require('node:util') const t = require('tap') const Node = require('../lib/node.js') const OverrideSet = require('../lib/override-set.js') const Link = require('../lib/link.js') const Shrinkwrap = require('../lib/shrinkwrap.js') -const { resolve } = require('path') +const { resolve } = require('node:path') const treeCheck = require('../lib/tree-check.js') const { normalizePath, normalizePaths } = require('./fixtures/utils.js') @@ -1072,7 +1072,7 @@ t.test('bin paths', t => { realpath: root.path + '/d/e/f', }) - const { resolve: r } = require('path') + const { resolve: r } = require('node:path') t.strictSame(root.binPaths, []) t.strictSame(link.binPaths, [ @@ -1131,7 +1131,7 @@ t.test('binPaths, but global', t => { realpath: root.path + '/d/e/f', }) - const { resolve: r } = require('path') + const { resolve: r } = require('node:path') t.strictSame(root.binPaths, []) t.strictSame(link.binPaths, process.platform === 'win32' diff --git a/workspaces/arborist/test/place-dep.js b/workspaces/arborist/test/place-dep.js index 292a2c8e23907..be98835fcc1f5 100644 --- a/workspaces/arborist/test/place-dep.js +++ b/workspaces/arborist/test/place-dep.js @@ -127,7 +127,7 @@ t.test('placement tests', t => { try { pd = place() } catch (er) { - console.error(require('util').inspect(er, { depth: Infinity })) + console.error(require('node:util').inspect(er, { depth: Infinity })) throw er } process.removeListener('log', onwarn) diff --git a/workspaces/arborist/test/printable.js b/workspaces/arborist/test/printable.js index 8d06059d5a221..cbdbbbfcaaa07 100644 --- a/workspaces/arborist/test/printable.js +++ b/workspaces/arborist/test/printable.js @@ -3,7 +3,7 @@ const Node = require('../lib/node.js') const Link = require('../lib/link.js') const Edge = require('../lib/edge.js') const printable = require('../lib/printable.js') -const util = require('util') +const util = require('node:util') t.cleanSnapshot = str => str // normalize paths diff --git a/workspaces/arborist/test/relpath.js b/workspaces/arborist/test/relpath.js index 458eb560a9fae..6043ab8332de4 100644 --- a/workspaces/arborist/test/relpath.js +++ b/workspaces/arborist/test/relpath.js @@ -1,7 +1,7 @@ const t = require('tap') // verify that we get \ converted to / by forcing win32 path mode -const path = require('path') +const path = require('node:path') const { win32 } = path path.relative = win32.relative diff --git a/workspaces/arborist/test/shrinkwrap.js b/workspaces/arborist/test/shrinkwrap.js index 7ec5d28c6f627..e3c604c096631 100644 --- a/workspaces/arborist/test/shrinkwrap.js +++ b/workspaces/arborist/test/shrinkwrap.js @@ -2,7 +2,7 @@ const Shrinkwrap = require('../lib/shrinkwrap.js') const Node = require('../lib/node.js') const Link = require('../lib/link.js') const calcDepFlags = require('../lib/calc-dep-flags.js') -const fs = require('fs') +const fs = require('node:fs') const Arborist = require('../lib/arborist/index.js') const t = require('tap') @@ -10,7 +10,7 @@ const t = require('tap') const normalizePath = path => path.replace(/[A-Z]:/, '').replace(/\\/g, '/') t.cleanSnapshot = s => s.split(process.cwd()).join('{CWD}') -const { resolve } = require('path') +const { resolve } = require('node:path') const fixture = resolve(__dirname, 'fixtures/install-types') const swonlyFixture = resolve(__dirname, 'fixtures/install-types-sw-only') const YarnLock = require('../lib/yarn-lock.js') diff --git a/workspaces/arborist/test/signal-handling.js b/workspaces/arborist/test/signal-handling.js index 344f60cf89958..3160683d75618 100644 --- a/workspaces/arborist/test/signal-handling.js +++ b/workspaces/arborist/test/signal-handling.js @@ -4,7 +4,7 @@ const onExit = require('../lib/signal-handling.js') t.equal(onExit.process, process, 'uses the real process by default') // ok, from here on out, use our mock -const EE = require('events') +const EE = require('node:events') const proc = onExit.process = new class MockProcess extends EE { constructor () { super() diff --git a/workspaces/arborist/test/spec-from-lock.js b/workspaces/arborist/test/spec-from-lock.js index af313e2f4faa0..c488be31b4a56 100644 --- a/workspaces/arborist/test/spec-from-lock.js +++ b/workspaces/arborist/test/spec-from-lock.js @@ -1,7 +1,7 @@ const sfl = require('../lib/spec-from-lock.js') const t = require('tap') const cwd = process.cwd() -const dirname = require('path').dirname(cwd) +const dirname = require('node:path').dirname(cwd) const normalizePath = path => path.replace(/[A-Z]:/, '').replace(/\\/g, '/') const isHGIFn = (key, val) => diff --git a/workspaces/arborist/test/tree-check.js b/workspaces/arborist/test/tree-check.js index 98fd6210456a5..4e95cc0239316 100644 --- a/workspaces/arborist/test/tree-check.js +++ b/workspaces/arborist/test/tree-check.js @@ -5,7 +5,7 @@ const treeCheck = t.mock('../lib/tree-check.js', { '../lib/debug.js': fn => fn(), }) -const { resolve } = require('path') +const { resolve } = require('node:path') const Node = require('../lib/node.js') const Link = require('../lib/link.js') diff --git a/workspaces/arborist/test/vuln.js b/workspaces/arborist/test/vuln.js index 6832ef89a4383..b1b21830d51aa 100644 --- a/workspaces/arborist/test/vuln.js +++ b/workspaces/arborist/test/vuln.js @@ -3,7 +3,7 @@ const Vuln = require('../lib/vuln.js') const Node = require('../lib/node.js') const Link = require('../lib/link.js') const Edge = require('../lib/edge.js') -const { resolve } = require('path') +const { resolve } = require('node:path') const semver = require('semver') const semverOpt = { includePrerelease: true, loose: true } diff --git a/workspaces/arborist/test/yarn-lock.js b/workspaces/arborist/test/yarn-lock.js index 1227237bf95f8..e1ed29701be0a 100644 --- a/workspaces/arborist/test/yarn-lock.js +++ b/workspaces/arborist/test/yarn-lock.js @@ -3,12 +3,12 @@ const Arborist = require('../lib/arborist') const Node = require('../lib/node.js') const t = require('tap') -const { resolve, basename } = require('path') +const { resolve, basename } = require('node:path') const fixtures = [ resolve(__dirname, 'fixtures/tap-with-yarn-lock'), resolve(__dirname, 'fixtures/yarn-stuff'), ] -const { readFileSync } = require('fs') +const { readFileSync } = require('node:fs') fixtures.forEach(f => t.test(basename(f), t => { const lockdata = readFileSync(f + '/yarn.lock') diff --git a/workspaces/config/lib/definitions/definitions.js b/workspaces/config/lib/definitions/definitions.js index 2978aa4b55dac..1b3fa69da9c49 100644 --- a/workspaces/config/lib/definitions/definitions.js +++ b/workspaces/config/lib/definitions/definitions.js @@ -7,7 +7,7 @@ const { join } = require('node:path') const isWindows = process.platform === 'win32' // used by cafile flattening to flatOptions.ca -const { readFileSync } = require('fs') +const { readFileSync } = require('node:fs') const maybeReadFile = file => { try { return readFileSync(file, 'utf8') @@ -61,7 +61,7 @@ const editor = process.env.EDITOR || const shell = isWindows ? process.env.ComSpec || 'cmd' : process.env.SHELL || 'sh' -const { networkInterfaces } = require('os') +const { networkInterfaces } = require('node:os') const getLocalAddresses = () => { try { return Object.values(networkInterfaces()).map( diff --git a/workspaces/config/lib/index.js b/workspaces/config/lib/index.js index 099bf2f5f15a0..e786828589aaf 100644 --- a/workspaces/config/lib/index.js +++ b/workspaces/config/lib/index.js @@ -13,7 +13,7 @@ const { unlink, stat, mkdir, -} = require('fs/promises') +} = require('node:fs/promises') const fileExists = (...p) => stat(resolve(...p)) .then((st) => st.isFile()) diff --git a/workspaces/config/test/definitions/definitions.js b/workspaces/config/test/definitions/definitions.js index 1b77bd0e811bf..2090e0dd32008 100644 --- a/workspaces/config/test/definitions/definitions.js +++ b/workspaces/config/test/definitions/definitions.js @@ -1,5 +1,5 @@ const t = require('tap') -const { resolve } = require('path') +const { resolve } = require('node:path') const mockGlobals = require('@npmcli/mock-globals') // have to fake the node version, or else it'll only pass on this one @@ -95,7 +95,7 @@ t.test('local-address allowed types', t => { eth69: [{ address: 'no place like home' }], }), } - const defs = mockDefs({ os }) + const defs = mockDefs({ 'node:os': os }) t.same(defs['local-address'].type, [ null, '127.0.0.1', @@ -110,7 +110,7 @@ t.test('local-address allowed types', t => { throw new Error('no network interfaces for some reason') }, } - const defs = mockDefs({ os }) + const defs = mockDefs({ 'node:os': os }) t.same(defs['local-address'].type, [null]) t.end() }) @@ -158,7 +158,7 @@ t.test('cache', t => { const flat = {} defsNix.cache.flatten('cache', { cache: '/some/cache/value' }, flat) - const { join } = require('path') + const { join } = require('node:path') t.equal(flat.cache, join('/some/cache/value', '_cacache')) t.equal(flat.npxCache, join('/some/cache/value', '_npx')) @@ -729,8 +729,8 @@ YYYY\r t.test('error other than ENOENT gets thrown', t => { const poo = new Error('poo') const defnReadFileThrows = mockDefs({ - fs: { - ...require('fs'), + 'node:fs': { + ...require('node:fs'), readFileSync: () => { throw poo }, diff --git a/workspaces/config/test/index.js b/workspaces/config/test/index.js index 70c3bc748a74c..67d49b28751dc 100644 --- a/workspaces/config/test/index.js +++ b/workspaces/config/test/index.js @@ -1,6 +1,6 @@ const t = require('tap') -const fs = require('fs') +const fs = require('node:fs') const { readFileSync } = fs // when running with `npm test` it adds environment variables that @@ -16,31 +16,35 @@ const createDef = (key, value) => ({ [key]: new Definition(key, { key, ...value const typeDefs = require('../lib/type-defs.js') -const { resolve, join, dirname } = require('path') +const { resolve, join, dirname } = require('node:path') -const fsMocks = { - 'fs/promises': { - ...fs.promises, - readFile: async (path, ...args) => { - if (path.includes('WEIRD-ERROR')) { - throw Object.assign(new Error('weird error'), { code: 'EWEIRD' }) - } +const mockFs = { + ...fs, + readFileSync: (path, ...args) => { + if (path.includes('WEIRD-ERROR')) { + throw Object.assign(new Error('weird error'), { code: 'EWEIRD' }) + } - return fs.promises.readFile(path, ...args) - }, + return fs.readFileSync(path, ...args) }, - fs: { - ...fs, - readFileSync: (path, ...args) => { - if (path.includes('WEIRD-ERROR')) { - throw Object.assign(new Error('weird error'), { code: 'EWEIRD' }) - } +} - return fs.readFileSync(path, ...args) - }, +const mockFsPromises = { + ...fs.promises, + readFile: async (path, ...args) => { + if (path.includes('WEIRD-ERROR')) { + throw Object.assign(new Error('weird error'), { code: 'EWEIRD' }) + } + + return fs.promises.readFile(path, ...args) }, } +const fsMocks = { + 'node:fs/promises': mockFsPromises, + 'node:fs': mockFs, +} + const { definitions, shorthands, flatten } = t.mock('../lib/definitions/index.js', fsMocks) const Config = t.mock('../', fsMocks) diff --git a/workspaces/config/test/parse-field.js b/workspaces/config/test/parse-field.js index 3dbeeae5f698f..fb8e064d956cd 100644 --- a/workspaces/config/test/parse-field.js +++ b/workspaces/config/test/parse-field.js @@ -1,6 +1,6 @@ const parseField = require('../lib/parse-field.js') const t = require('tap') -const { resolve } = require('path') +const { resolve } = require('node:path') const defs = require('../lib/definitions/definitions.js') const types = Object.entries(defs).map(([k, v]) => [k, v.type]) diff --git a/workspaces/config/test/set-envs.js b/workspaces/config/test/set-envs.js index 54aa4022fc350..b62ab60955521 100644 --- a/workspaces/config/test/set-envs.js +++ b/workspaces/config/test/set-envs.js @@ -1,7 +1,7 @@ const setEnvs = require('../lib/set-envs.js') const mockGlobals = require('@npmcli/mock-globals') -const { join } = require('path') +const { join } = require('node:path') const t = require('tap') const { execPath } = process const cwd = process.cwd() diff --git a/workspaces/config/test/type-defs.js b/workspaces/config/test/type-defs.js index 2ce0ac91dc4cd..89ca3e53cd03e 100644 --- a/workspaces/config/test/type-defs.js +++ b/workspaces/config/test/type-defs.js @@ -8,7 +8,7 @@ const { validate: validatePath, }, } = typeDefs -const { resolve } = require('path') +const { resolve } = require('node:path') const d = { semver: 'foobar', somePath: true } t.equal(validateSemver(d, 'semver', 'foobar'), false) diff --git a/workspaces/libnpmdiff/lib/should-print-patch.js b/workspaces/libnpmdiff/lib/should-print-patch.js index f8277a809eef6..8000fc5e6afc1 100644 --- a/workspaces/libnpmdiff/lib/should-print-patch.js +++ b/workspaces/libnpmdiff/lib/should-print-patch.js @@ -1,4 +1,4 @@ -const { basename, extname } = require('path') +const { basename, extname } = require('node:path') const binaryExtensions = require('binary-extensions') diff --git a/workspaces/libnpmdiff/lib/tarball.js b/workspaces/libnpmdiff/lib/tarball.js index 41ea84a6885a5..e2738b58f11bc 100644 --- a/workspaces/libnpmdiff/lib/tarball.js +++ b/workspaces/libnpmdiff/lib/tarball.js @@ -1,4 +1,4 @@ -const { relative } = require('path') +const { relative } = require('node:path') const Arborist = require('@npmcli/arborist') const npa = require('npm-package-arg') diff --git a/workspaces/libnpmdiff/test/index.js b/workspaces/libnpmdiff/test/index.js index cccde429baa00..bb60fe1338667 100644 --- a/workspaces/libnpmdiff/test/index.js +++ b/workspaces/libnpmdiff/test/index.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') diff --git a/workspaces/libnpmdiff/test/tarball.js b/workspaces/libnpmdiff/test/tarball.js index cb61556286879..e182c159bc541 100644 --- a/workspaces/libnpmdiff/test/tarball.js +++ b/workspaces/libnpmdiff/test/tarball.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const tar = require('tar') diff --git a/workspaces/libnpmdiff/test/untar.js b/workspaces/libnpmdiff/test/untar.js index 62be1c6ba9003..19e55b7d006fb 100644 --- a/workspaces/libnpmdiff/test/untar.js +++ b/workspaces/libnpmdiff/test/untar.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const pacote = require('pacote') const untar = require('../lib/untar.js') diff --git a/workspaces/libnpmexec/lib/file-exists.js b/workspaces/libnpmexec/lib/file-exists.js index 55c04bd4dc547..8a1a88adee993 100644 --- a/workspaces/libnpmexec/lib/file-exists.js +++ b/workspaces/libnpmexec/lib/file-exists.js @@ -1,5 +1,5 @@ -const { resolve } = require('path') -const { stat } = require('fs/promises') +const { resolve } = require('node:path') +const { stat } = require('node:fs/promises') const { walkUp } = require('walk-up-path') const fileExists = async (file) => { diff --git a/workspaces/libnpmexec/lib/index.js b/workspaces/libnpmexec/lib/index.js index 28cba79a7f227..0ac2c076761f6 100644 --- a/workspaces/libnpmexec/lib/index.js +++ b/workspaces/libnpmexec/lib/index.js @@ -1,9 +1,9 @@ 'use strict' -const { mkdir } = require('fs/promises') +const { mkdir } = require('node:fs/promises') const Arborist = require('@npmcli/arborist') const ciInfo = require('ci-info') -const crypto = require('crypto') +const crypto = require('node:crypto') const { log, input } = require('proc-log') const npa = require('npm-package-arg') const pacote = require('pacote') @@ -14,7 +14,7 @@ const getBinFromManifest = require('./get-bin-from-manifest.js') const noTTY = require('./no-tty.js') const runScript = require('./run-script.js') const isWindows = require('./is-windows.js') -const { dirname, resolve } = require('path') +const { dirname, resolve } = require('node:path') const binPaths = [] diff --git a/workspaces/libnpmexec/test/fixtures/setup.js b/workspaces/libnpmexec/test/fixtures/setup.js index 84c404cbb9ca2..c4bb1cb53db08 100644 --- a/workspaces/libnpmexec/test/fixtures/setup.js +++ b/workspaces/libnpmexec/test/fixtures/setup.js @@ -1,7 +1,7 @@ -const fs = require('fs/promises') -const { existsSync } = require('fs') -const { resolve, extname, join } = require('path') +const fs = require('node:fs/promises') +const { existsSync } = require('node:fs') +const { resolve, extname, join } = require('node:path') const binLinks = require('bin-links') const MockRegistry = require('@npmcli/mock-registry') const justExtend = require('just-extend') diff --git a/workspaces/libnpmexec/test/local.js b/workspaces/libnpmexec/test/local.js index ddfb8f5429e1a..ecc7cdd881237 100644 --- a/workspaces/libnpmexec/test/local.js +++ b/workspaces/libnpmexec/test/local.js @@ -1,7 +1,7 @@ const { log } = require('proc-log') -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') -const fs = require('fs/promises') +const fs = require('node:fs/promises') const { resetSeen: resetSeenLinks } = require('bin-links') const { setup, createPkg, merge } = require('./fixtures/setup.js') diff --git a/workspaces/libnpmexec/test/prompt.js b/workspaces/libnpmexec/test/prompt.js index 8c8c520d497b6..68fa4a2466df0 100644 --- a/workspaces/libnpmexec/test/prompt.js +++ b/workspaces/libnpmexec/test/prompt.js @@ -1,7 +1,7 @@ const procLog = require('proc-log') -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') -const fs = require('fs/promises') +const fs = require('node:fs/promises') const { setup, createPkg, merge } = require('./fixtures/setup.js') t.test('prompt, accepts', async t => { diff --git a/workspaces/libnpmexec/test/registry.js b/workspaces/libnpmexec/test/registry.js index 45d7cf4654541..8af792018c954 100644 --- a/workspaces/libnpmexec/test/registry.js +++ b/workspaces/libnpmexec/test/registry.js @@ -1,4 +1,4 @@ -const { resolve } = require('path') +const { resolve } = require('node:path') const t = require('tap') const { setup, createPkg, merge } = require('./fixtures/setup.js') diff --git a/workspaces/libnpmfund/lib/index.js b/workspaces/libnpmfund/lib/index.js index 39b69afc0abcc..1616c88b73c50 100644 --- a/workspaces/libnpmfund/lib/index.js +++ b/workspaces/libnpmfund/lib/index.js @@ -1,6 +1,6 @@ 'use strict' -const URL = require('url').URL +const URL = require('node:url').URL const Arborist = require('@npmcli/arborist') // supports object funding and string shorthand, or an array of these diff --git a/workspaces/libnpmfund/test/index.js b/workspaces/libnpmfund/test/index.js index 0a84e62bc7d84..e9864c23e7fd1 100644 --- a/workspaces/libnpmfund/test/index.js +++ b/workspaces/libnpmfund/test/index.js @@ -7,7 +7,7 @@ const { normalizeFunding, isValidFunding, } = require('../lib/index.js') -const { join } = require('path') +const { join } = require('node:path') t.test('symlink tree', async (t) => { const path = t.testdir({ diff --git a/workspaces/libnpmpack/lib/index.js b/workspaces/libnpmpack/lib/index.js index c71716cf54428..b026ad1a935c7 100644 --- a/workspaces/libnpmpack/lib/index.js +++ b/workspaces/libnpmpack/lib/index.js @@ -3,9 +3,9 @@ const pacote = require('pacote') const npa = require('npm-package-arg') const runScript = require('@npmcli/run-script') -const path = require('path') +const path = require('node:path') const Arborist = require('@npmcli/arborist') -const { writeFile } = require('fs/promises') +const { writeFile } = require('node:fs/promises') module.exports = pack async function pack (spec = 'file:.', opts = {}) { diff --git a/workspaces/libnpmpack/test/index.js b/workspaces/libnpmpack/test/index.js index ee34cd2c94c10..f5eb647e4153b 100644 --- a/workspaces/libnpmpack/test/index.js +++ b/workspaces/libnpmpack/test/index.js @@ -5,8 +5,8 @@ const t = require('tap') const tspawk = require('./fixtures/tspawk.js') const spawk = tspawk(t) -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') const pack = require('../lib/index.js') const tnock = require('./fixtures/tnock.js') diff --git a/workspaces/libnpmpublish/lib/provenance.js b/workspaces/libnpmpublish/lib/provenance.js index 090d4cd7fe561..cead8da6be34f 100644 --- a/workspaces/libnpmpublish/lib/provenance.js +++ b/workspaces/libnpmpublish/lib/provenance.js @@ -1,5 +1,5 @@ const sigstore = require('sigstore') -const { readFile } = require('fs/promises') +const { readFile } = require('node:fs/promises') const ci = require('ci-info') const { env } = process diff --git a/workspaces/libnpmpublish/lib/publish.js b/workspaces/libnpmpublish/lib/publish.js index 9ffbc93426309..93d546efb5f0e 100644 --- a/workspaces/libnpmpublish/lib/publish.js +++ b/workspaces/libnpmpublish/lib/publish.js @@ -3,7 +3,7 @@ const npmFetch = require('npm-registry-fetch') const npa = require('npm-package-arg') const { log } = require('proc-log') const semver = require('semver') -const { URL } = require('url') +const { URL } = require('node:url') const ssri = require('ssri') const ciInfo = require('ci-info') diff --git a/workspaces/libnpmpublish/lib/unpublish.js b/workspaces/libnpmpublish/lib/unpublish.js index 9b124c11435fb..983a5d2c39068 100644 --- a/workspaces/libnpmpublish/lib/unpublish.js +++ b/workspaces/libnpmpublish/lib/unpublish.js @@ -1,6 +1,6 @@ 'use strict' -const { URL } = require('url') +const { URL } = require('node:url') const npa = require('npm-package-arg') const npmFetch = require('npm-registry-fetch') const semver = require('semver') diff --git a/workspaces/libnpmpublish/test/publish.js b/workspaces/libnpmpublish/test/publish.js index b9875097bf538..a3355df7417a9 100644 --- a/workspaces/libnpmpublish/test/publish.js +++ b/workspaces/libnpmpublish/test/publish.js @@ -1,7 +1,7 @@ 'use strict' -const crypto = require('crypto') -const fs = require('fs') +const crypto = require('node:crypto') +const fs = require('node:fs') const npa = require('npm-package-arg') const ssri = require('ssri') const t = require('tap') diff --git a/workspaces/libnpmsearch/test/index.js b/workspaces/libnpmsearch/test/index.js index dd54949dae613..2aba48611c5e6 100644 --- a/workspaces/libnpmsearch/test/index.js +++ b/workspaces/libnpmsearch/test/index.js @@ -1,6 +1,6 @@ 'use strict' -const qs = require('querystring') +const qs = require('node:querystring') const test = require('tap').test const tnock = require('./fixtures/tnock.js') diff --git a/workspaces/libnpmversion/lib/read-json.js b/workspaces/libnpmversion/lib/read-json.js index 32c7289507697..d5d47565a41ab 100644 --- a/workspaces/libnpmversion/lib/read-json.js +++ b/workspaces/libnpmversion/lib/read-json.js @@ -1,6 +1,6 @@ // can't use read-package-json-fast, because we want to ensure // that we make as few changes as possible, even for safety issues. -const { readFile } = require('fs/promises') +const { readFile } = require('node:fs/promises') const parse = require('json-parse-even-better-errors') module.exports = async path => parse(await readFile(path)) diff --git a/workspaces/libnpmversion/lib/write-json.js b/workspaces/libnpmversion/lib/write-json.js index 425be8e8e3efb..2f19953d75d28 100644 --- a/workspaces/libnpmversion/lib/write-json.js +++ b/workspaces/libnpmversion/lib/write-json.js @@ -1,5 +1,5 @@ // write the json back, preserving the line breaks and indent -const { writeFile } = require('fs/promises') +const { writeFile } = require('node:fs/promises') const kIndent = Symbol.for('indent') const kNewline = Symbol.for('newline') diff --git a/workspaces/libnpmversion/test/write-json.js b/workspaces/libnpmversion/test/write-json.js index 63dccf6cf5d0e..98c67897c53c9 100644 --- a/workspaces/libnpmversion/test/write-json.js +++ b/workspaces/libnpmversion/test/write-json.js @@ -1,7 +1,7 @@ const t = require('tap') -const path = require('path') +const path = require('node:path') const writeJson = require('../lib/write-json.js') -const { readFile } = require('fs/promises') +const { readFile } = require('node:fs/promises') const kIndent = Symbol.for('indent') const kNewline = Symbol.for('newline')