Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "node:" prefixed imports everywhere #250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ jobs:
build:
strategy:
matrix:
node-version: [10.0.x, 10.x, 12.0.x, 12.x, 14.0.x, 14.x, 15.x]
node-version: [14.8.0, 14, 16.0.0, 16]
os: [ubuntu-latest, macOS-latest, windows-latest]
exclude:
# Node 14 is not available on macos anymore
- os: macos-latest
node-version: 14
- os: macos-latest
node-version: 14.18.0
fail-fast: false

runs-on: ${{ matrix.os }}
Expand All @@ -17,7 +23,7 @@ jobs:
uses: actions/[email protected]

- name: Use Nodejs ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
6 changes: 3 additions & 3 deletions graceful-fs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var fs = require('fs')
var fs = require('node:fs')
var polyfills = require('./polyfills.js')
var legacy = require('./legacy-streams.js')
var clone = require('./clone.js')

var util = require('util')
var util = require('node:util')

/* istanbul ignore next - node 0.x polyfill */
var gracefulQueue
Expand Down Expand Up @@ -84,7 +84,7 @@ if (!fs[gracefulQueue]) {
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
process.on('exit', function() {
debug(fs[gracefulQueue])
require('assert').equal(fs[gracefulQueue].length, 0)
require('node:assert').equal(fs[gracefulQueue].length, 0)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion legacy-streams.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Stream = require('stream').Stream
var Stream = require('node:stream').Stream

module.exports = legacy

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
"EACCESS"
],
"license": "ISC",
"engines": {
"node": ">=14.18.0 <15 || >=16"
},
"devDependencies": {
"import-fresh": "^2.0.0",
"mkdirp": "^0.5.0",
Expand Down
6 changes: 3 additions & 3 deletions polyfills.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var constants = require('constants')
var constants = require('node:fs').constants

var origCwd = process.cwd
var cwd = null
Expand Down Expand Up @@ -31,7 +31,7 @@ function patch (fs) {

// lchmod, broken prior to 0.6.2
// back-port the fix here.
if (constants.hasOwnProperty('O_SYMLINK') &&
if (constants.O_SYMLINK !== undefined &&
process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
patchLchmod(fs)
}
Expand Down Expand Up @@ -206,7 +206,7 @@ function patch (fs) {
}

function patchLutimes (fs) {
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
if (constants.O_SYMLINK !== undefined && fs.futimes) {
fs.lutimes = function (path, at, mt, cb) {
fs.open(path, constants.O_SYMLINK, function (er, fd) {
if (er) {
Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var fs = require('fs')
var fs = require('node:fs')
var tap = require('tap')
var dir = __dirname + '/test'
var node = process.execPath
var path = require('path')
var path = require('node:path')

var files = fs.readdirSync(dir)
var env = Object.keys(process.env).reduce(function (env, k) {
Expand All @@ -12,7 +12,7 @@ var env = Object.keys(process.env).reduce(function (env, k) {
TEST_GRACEFUL_FS_GLOBAL_PATCH: 1
})

tap.jobs = require('os').cpus().length
tap.jobs = require('node:os').cpus().length
var testFiles = files.filter(function (f) {
return (/\.js$/.test(f) && fs.statSync(dir + '/' + f).isFile())
})
Expand Down
2 changes: 1 addition & 1 deletion test/chown-er-ok.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var realFs = require('fs')
var realFs = require('node:fs')

var methods = ['chown', 'chownSync', 'chmod', 'chmodSync']
methods.forEach(function (method) {
Expand Down
4 changes: 2 additions & 2 deletions test/close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fs = require('fs')
var path = require('path')
var fs = require('node:fs')
var path = require('node:path')
var gfsPath = path.resolve(__dirname, '..', 'graceful-fs.js')
var gfs = require(gfsPath)
var importFresh = require('import-fresh')
Expand Down
2 changes: 1 addition & 1 deletion test/monkeypatch-by-accident.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) {
process.exit(0)
}

const fs = require('fs')
const fs = require('node:fs')

// Save originals before loading graceful-fs
const names = [
Expand Down
2 changes: 1 addition & 1 deletion test/read-write-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var t = require('tap')
var td = t.testdir({
files: {}
})
var p = require('path').resolve(td, 'files')
var p = require('node:path').resolve(td, 'files')

process.chdir(td)

Expand Down
2 changes: 1 addition & 1 deletion test/readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var t = require('tap')
var td = t.testdir({
files: {}
})
var p = require('path').resolve(td, 'files')
var p = require('node:path').resolve(td, 'files')

process.chdir(td)

Expand Down
4 changes: 2 additions & 2 deletions test/retry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

var importFresh = require('import-fresh')
var path = require('path')
var realFs = require('fs')
var path = require('node:path')
var realFs = require('node:fs')
var test = require('tap').test

var EMFILE = Object.assign(new Error('FAKE EMFILE'), { code: 'EMFILE' })
Expand Down
4 changes: 2 additions & 2 deletions test/stats-uid-gid.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var util = require('util')
var fs = require('fs')
var util = require('node:util')
var fs = require('node:fs')
var test = require('tap').test

// mock fs.statSync to return signed uids/gids
Expand Down
2 changes: 1 addition & 1 deletion test/stats.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fs = require('fs')
var fs = require('node:fs')
var gfs = require('../graceful-fs.js')
var test = require('tap').test

Expand Down
2 changes: 1 addition & 1 deletion test/windows-rename-polyfill.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process.env.GRACEFUL_FS_PLATFORM = 'win32'
var t = require('tap')

var fs = require('fs')
var fs = require('node:fs')

var ers = ['EPERM', 'EBUSY', 'EACCES']
t.plan(ers.length)
Expand Down
2 changes: 1 addition & 1 deletion test/write-then-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var mkdirp = require('mkdirp')
var t = require('tap')

var td = t.testdir({ files: {} })
var p = require('path').resolve(td, 'files')
var p = require('node:path').resolve(td, 'files')

process.chdir(td)

Expand Down
2 changes: 1 addition & 1 deletion test/zzz-avoid-memory-leak.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var importFresh = require('import-fresh');
var t = require('tap')
var v8
try {
v8 = require('v8')
v8 = require('node:v8')
} catch (er) {}

if (!v8 || !v8.getHeapStatistics || typeof v8.getHeapStatistics().number_of_detached_contexts !== 'number') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/zzz-avoid-memory-leak.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gggg

Expand Down