mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-27 19:41:44 -04:00
Add n/prefer-node-protocol rule and autofix all bare builtin imports to use the node: prefix. Simplify the simple-import-sort builtins pattern to just ^node: since all imports now use the prefix.
23 lines
637 B
TypeScript
23 lines
637 B
TypeScript
import fs from 'node:fs'
|
|
|
|
import isWindows from 'is-windows'
|
|
import isExe from 'isexe'
|
|
|
|
const IS_WINDOWS = isWindows()
|
|
|
|
// eslint-disable-next-line
|
|
export default (ok: (value: any, comment: string) => void, filePath: string): void => {
|
|
if (IS_WINDOWS) {
|
|
if (fs.existsSync(`${filePath}.cmd`)) {
|
|
ok(isExe.sync(`${filePath}.cmd`), `${filePath}.cmd is executable`)
|
|
} else {
|
|
ok(isExe.sync(`${filePath}.exe`), `${filePath}.exe is executable`)
|
|
}
|
|
return
|
|
}
|
|
|
|
const stat = fs.statSync(filePath)
|
|
ok((stat.mode & 0o111) === 0o111, `${filePath} is executable`)
|
|
ok(stat.isFile(), `${filePath} refers to a file`)
|
|
}
|