-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(npm): startup time reduce (#705)
* perf(`npm/lefthook`): use `optionalDependencies` `bin` field * perf(`npm/@evilmartians/lefthook`): update `binary` at postinstall * perf(`@evilmartians/lefthook-installer`): use `postinstall` binary * fix(`@evilmartians/lefthook`): typo fix * fix(`@evilmartians/lefthook-installer`): typo fix * revert(`@npm-*`): restore old behavior and fix `pkg` `main` field * chore(`npm-bundled`): add missing `bin` removed on prev commit
- Loading branch information
Showing
14 changed files
with
41 additions
and
36 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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,20 +1,20 @@ | ||
const path = require("path") | ||
const path = require("path"); | ||
|
||
function getExePath() { | ||
// Detect OS | ||
// https://nodejs.org/api/process.html#process_process_platform | ||
let os = process.platform; | ||
let extension = ''; | ||
if (['win32', 'cygwin'].includes(process.platform)) { | ||
os = 'windows'; | ||
extension = '.exe'; | ||
let extension = ""; | ||
if (["win32", "cygwin"].includes(process.platform)) { | ||
os = "windows"; | ||
extension = ".exe"; | ||
} | ||
|
||
// Detect architecture | ||
// https://nodejs.org/api/process.html#process_process_arch | ||
let arch = process.arch; | ||
|
||
return require.resolve(`lefthook-${os}-${arch}/bin/lefthook${extension}`) | ||
return require.resolve(`lefthook-${os}-${arch}/bin/lefthook${extension}`); | ||
} | ||
|
||
exports.getExePath = getExePath; |
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,19 +1,21 @@ | ||
const { spawnSync } = require("child_process") | ||
const { getExePath } = require("./get-exe") | ||
const { spawnSync } = require("child_process"); | ||
const { getExePath } = require("./get-exe"); | ||
|
||
function install() { | ||
if (process.env.CI) { | ||
return | ||
return; | ||
} | ||
|
||
spawnSync(getExePath(), ["install", "-f"], { | ||
cwd: process.env.INIT_CWD || process.cwd(), | ||
stdio: "inherit", | ||
}) | ||
}); | ||
} | ||
|
||
try { | ||
install() | ||
} catch(e) { | ||
console.warn("'lefthook install' command failed. Try running it manually.\n" + e) | ||
install(); | ||
} catch (e) { | ||
console.warn( | ||
"'lefthook install' command failed. Try running it manually.\n" + e, | ||
); | ||
} |