-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: drop zx in favor of simple Node script
- Loading branch information
Showing
2 changed files
with
41 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,44 @@ | ||
#!/usr/bin/env zx | ||
#!/usr/bin/env node | ||
|
||
const { | ||
CI, | ||
INIT_CWD, | ||
} = process.env; | ||
import { spawn } from 'node:child_process' | ||
import { readFile } from 'node:fs/promises'; | ||
|
||
const { | ||
name: moduleName, | ||
} = JSON.parse(await fs.readFile('./package.json', { encoding: 'utf-8' })); | ||
CI = false, | ||
INIT_CWD = '', | ||
} = process.env; | ||
|
||
if ( | ||
CI != 'true' && | ||
!INIT_CWD.endsWith(`node_modules/${moduleName}`) && | ||
INIT_CWD.endsWith(moduleName) | ||
CI !== 'true' | ||
) { | ||
await $`simple-git-hooks && npm dedupe`; | ||
const { | ||
name: moduleName, | ||
} = JSON.parse(await readFile('./package.json', { encoding: 'utf-8' })); | ||
|
||
if ( | ||
!INIT_CWD.endsWith(`node_modules/${moduleName}`) && | ||
INIT_CWD.endsWith(moduleName) | ||
) { | ||
const cmd = 'simple-git-hooks && npm dedupe'; | ||
|
||
process.stdout.write(cmd); | ||
process.stdout.write('\n\n'); | ||
|
||
const postinstall = spawn( | ||
cmd, | ||
[], | ||
{ | ||
shell: true, | ||
windowsHide: true, | ||
} | ||
); | ||
|
||
postinstall.stdout.on('data', (data) => { | ||
process.stdout.write(data); | ||
}); | ||
|
||
postinstall.stderr.on('data', (data) => { | ||
process.stderr.write(data); | ||
}); | ||
} | ||
} |