diff --git a/index.ts b/index.ts index c613c848..f41bacb8 100755 --- a/index.ts +++ b/index.ts @@ -291,6 +291,10 @@ commander .command('clone [scriptId] [versionNumber]') .description('Clone a project') .action(async (scriptId: string, versionNumber?: number) => { + await checkIfOnline(); + if (fs.existsSync(DOT.PROJECT.PATH)) { + logError(null, ERROR.FOLDER_EXISTS); + } else { if (!scriptId) { getAPICredentials(async () => { const drive = google.drive({version: 'v3', auth: oauth2Client}) as Drive; @@ -325,11 +329,11 @@ commander } }); } else { - await checkIfOnline(); spinner.setSpinnerTitle(LOG.CLONING); saveProjectId(scriptId); fetchProject(scriptId, '', versionNumber); } + } }); /** diff --git a/src/utils.ts b/src/utils.ts index 7e3b216c..3b6dd843 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -134,6 +134,7 @@ export const logError = (err: any, description = '') => { } if (description) console.error(description); } + process.exit(1); }; /** diff --git a/tests/test.ts b/tests/test.ts index 8de3ceec..9ef333f1 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -71,6 +71,7 @@ describe.skip('Test clasp create