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

perf: use node: prefix to bypass require.cache call for builtins #68

Merged
merged 2 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const spawn = require('cross-spawn')
const which = require('which')
const path = require('path')
const util = require('util')
const tty = require('tty')
const path = require('node:path')
const util = require('node:util')
const tty = require('node:tty')

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

/**
* Representation of a hook runner.
Expand Down
6 changes: 3 additions & 3 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//
// Compatibility with older node.js as path.exists got moved to `fs`.
//
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 hook = path.join(__dirname, 'hook')
const root = path.resolve(__dirname, '..', '..', '..')
const exists = fs.existsSync || path.existsSync
Expand Down
8 changes: 4 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
const t = require('tap')
const Hook = require('./')
const tty = require('tty')
const tty = require('node:tty')
const ttySupportColor = tty.isatty(process.stdout.fd)

const proxyquire = require('proxyquire')
Expand Down Expand Up @@ -147,7 +147,7 @@ t.test('pre-commit', function (t) {
t.plan(1)

const Hook = proxyquire('.', {
fs: {
'node:fs': {
existsSync () {
return true
},
Expand All @@ -168,7 +168,7 @@ t.test('pre-commit', function (t) {
t.plan(4)

let Hook = proxyquire('.', {
fs: {
'node:fs': {
existsSync () {
return true
},
Expand All @@ -181,7 +181,7 @@ t.test('pre-commit', function (t) {
hook = new Hook(exit)

Hook = proxyquire('.', {
fs: {
'node:fs': {
existsSync () { return true },
readFileSync () {
return Buffer.from('{ "bad": [json }')
Expand Down
4 changes: 2 additions & 2 deletions uninstall.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const exists = fs.existsSync || path.existsSync
const root = path.resolve(__dirname, '..', '..', '..')
let git = path.resolve(root, '.git')
Expand Down