-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make hasYarn & hasGit lazy to improve boot time
- Loading branch information
Showing
7 changed files
with
27 additions
and
18 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,26 +1,35 @@ | ||
const { execSync } = require('child_process') | ||
|
||
let _hasYarn | ||
let _hasGit | ||
|
||
// env detection | ||
exports.hasYarn = (() => { | ||
exports.hasYarn = () => { | ||
if (process.env.VUE_CLI_TEST) { | ||
return true | ||
} | ||
if (_hasYarn != null) { | ||
return _hasYarn | ||
} | ||
try { | ||
execSync('yarnpkg --version', { stdio: 'ignore' }) | ||
return true | ||
return (_hasYarn = true) | ||
} catch (e) { | ||
return false | ||
return (_hasYarn = false) | ||
} | ||
})() | ||
} | ||
|
||
exports.hasGit = () => { | ||
if (process.env.VUE_CLI_TEST) { | ||
return true | ||
} | ||
if (_hasGit != null) { | ||
return _hasGit | ||
} | ||
try { | ||
execSync('git --version', { stdio: 'ignore' }) | ||
return true | ||
return (_hasGit = true) | ||
} catch (e) { | ||
return false | ||
return (_hasGit = false) | ||
} | ||
} |
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