fix: no more crashing cli if yarn isnt present (#24)

* fix: no more crashing cli if yarn isnt present

* chore: add .idea to gitignore

* chore: fix position of .idea

Co-authored-by: jacoobes <jacobnguyend@gmail.com>
This commit is contained in:
Evo
2022-05-13 23:57:58 +05:30
committed by GitHub
parent 85381e13a4
commit 88893a35cd
3 changed files with 6 additions and 5 deletions

5
.gitignore vendored
View File

@@ -9,8 +9,9 @@ lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# VSCode
# Editor Files
.vscode
.idea
# Runtime data
pids
@@ -113,4 +114,4 @@ dist
# Yarn files
.yarn/install-state.gz
.yarn/build-state.yml
.yarn/build-state.yml

View File

@@ -47,7 +47,7 @@ export async function init({ flags }) {
} else {
data = await prompt([name, lang, main_dir, cmds_dir, default_prefix]);
git_init = (await prompt([gitInit])).gitinit;
await npm();
pm = await npm();
}
if (Object.keys(data).length < 5) process.exit(1);

View File

@@ -5,10 +5,10 @@ import { execa } from 'execa';
* @returns A promise that resolves to a string.
*/
export async function npm() {
const npm = await execa('npm', ['-v']);
const npm = await execa('npm', ['-v']).catch(() => null);
const npm_version = npm?.stdout;
const yarn = await execa('yarn', ['-v']);
const yarn = await execa('yarn', ['-v']).catch(() => null);
const yarn_version = yarn?.stdout;
if (npm_version && !yarn_version) {