-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 672 #673
Issue 672 #673
Conversation
use forEach instead of map when return value is not used (google#614)
Dependencies (google#615)
* dependencies clean-up * types for child_process' spawnSync * types for child_process' spawnSync + options fix * linting
* relative rootDir support * relative rootDir support (untrackedFiles behavior changed) * relative rootDir doc changes
* prettier + sort imports * splitLines types * unused package 'connect' * ucfirst, isOnline types * ellipsize types * redundant package 'fs-copy-file-sync' * removing extra line * // TODO * packages dependencies update * comment fix * fixes * nicer ellipsize typing * better?
* regroup `inquirer` into a single file * fix typo * linting * switch to `find-up` * switch to `find-up` & `strip-bom` * dependencies update * findUp implementation fix * enum accessor fix * fs-extra & typescript dependency fix * linting * dependencies clean-up (again) * non any cast
@grant if you prefer, I can change to always use ‘return logError(…)’ for clarity? |
Thanks. For example, import changes should be included in this PR. Added some comments. |
Sorry but I unsure I fully understand your comment :)
Just to be sure, package versions upgrade in |
@@ -51,7 +47,7 @@ export async function getFunctionNames(script: script_v1.Script, scriptId: strin | |||
// TODO: unnecessary export | |||
export async function getProjectIdWithErrors() { | |||
const projectId = await getProjectId(); // will prompt user to set up if required | |||
if (!projectId) throw logError(null, ERROR.NO_GCLOUD_PROJECT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this throw
specifically blocks the return
from happening.
I don't know if the caller of getProjectIdWithErrors
handles an empty return value, but probably not. I'll still throw here and elsewhere for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logError() never returns to the caller but always ends the node process.
We could make a choice to:
- rename it to something more descriptive like logErrorAndDie ;)
- always throw logError
@@ -330,7 +329,7 @@ export async function checkOauthScopes(rc: ClaspToken) { | |||
await oauthScopesPrompt() | |||
.then(async (answers) => { | |||
if (answers.doAuth) { | |||
if (!rc.isLocalCreds) return logError(null, ERROR.NO_LOCAL_CREDENTIALS); | |||
if (!rc.isLocalCreds) logError(null, ERROR.NO_LOCAL_CREDENTIALS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return is needed. Otherwise we try to auth with no credentials.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -65,10 +64,7 @@ export default async (cmd: { type: string; title: string; parentId: string; root | |||
spinner.setSpinnerTitle(LOG.CREATE_PROJECT_START(title)).start(); | |||
try { | |||
const { scriptId } = await getProjectSettings(true); | |||
if (scriptId) { | |||
logError(null, ERROR.NO_NESTED_PROJECTS); | |||
process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this isn't needed? I wouldn't add it unless it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
logError() now has an optional parameter it’ll use with process.exit()
getProjectSettings().then(projectSettings => { | ||
console.log(`${LOG.OPEN_LINK(LOG.SCRIPT_LINK(projectSettings.scriptId))}\n`); | ||
console.log(`${LOG.GET_PROJECT_ID_INSTRUCTIONS}\n`); | ||
projectIdPrompt() | ||
.then(answers => { | ||
projectId = answers.projectId; | ||
const dotfile = DOTFILE.PROJECT(); | ||
if (!dotfile) return reject(logError(null, ERROR.SETTINGS_DNE)); | ||
if (!dotfile) logError(null, ERROR.SETTINGS_DNE); | ||
dotfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this will fail. Is this on purpose?
I don't know if all the cases are handled. Maybe we can explain the way this works in a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since logError always end by calling process.exit() it should not change anything.
I opened this issue/PR because in many places of the source, the usage of logError() was (misleadingly) hinting that it would return and resume execution (which doesn’t”t occur ever)
Thanks. |
I initiated this PR just because of this, use of |
Fixes #672
npm run test
succeeds.npm run lint
succeeds.