Skip to content

Conversation

@vishrutshah
Copy link
Contributor

Fixes #1993

@dnfclas
Copy link

dnfclas commented Feb 6, 2018

CLA assistant check
All CLA requirements met.

Copy link
Contributor

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM. Thanks for the submission!

  • Gregg


// Read existing Tasks configuration
const tasksConfigs = vscode.workspace.getConfiguration('tasks');
let existingTaskConfigs = tasksConfigs.get<Array<tasks.TaskDescription>>('tasks');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishrutshah thanks for sending this! One question on this - did you test the behavior if you do NOT already have a tasks.json, or if the task.json has no real content to see if you need additional if statements there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified with having no task.json at all but let me also verify if tasks.json is having empty content :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. So after testing both the scenarios, looks like we do not need addition if statements around

let existingTaskConfigs = tasksConfigs.get<Array<tasks.TaskDescription>>('tasks');

Case 1: When we do not have tasks.json then getConfiguration returns an object on which we call get<T> which returns undefined
Case 2: When we have tasks.json with empty array of tasks then we do not visit this path as we existing logic resolve({ updateTasksJson: buildTasks.length === 0 }); would prevent from modifying the tasks.json

Let me know your thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishrutshah your analysis sounds correct to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Let me know if any more changes are required. Happy to do it :)

src/assets.ts Outdated
if (existingLaunchConfigs) {
launchJson = launchJson.substring(0, launchJson.length-1);
let existingLaunchConfigsString = JSON.stringify(existingLaunchConfigs, null, ' ');
existingLaunchConfigsString = existingLaunchConfigsString.substring(1, existingLaunchConfigsString.length-1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case there is trailing white space, we should probably look for the last index of ']' rather than just assuming it is the very character in the buffer

@vishrutshah
Copy link
Contributor Author

@gregg-miskelly Could you please help me see what I may doing wrong here as CI is failing? Thanks!

@vishrutshah
Copy link
Contributor Author

Aha seems like I was missing updates from upstream :-)

src/assets.ts Outdated
let existingLaunchConfigsString = JSON.stringify(existingLaunchConfigs, null, ' ');
const lastBracket = launchJson.lastIndexOf(']');
const lastBracketInExistingConfig = existingLaunchConfigsString.lastIndexOf(']');
const firstBracketInExistingConfig = existingLaunchConfigsString.lastIndexOf('[');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On this line, don't you want existingLaunchConfigsString.indexOf('['); instead of lastIndexOf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. My mistake. It did work as there was only one occurrence of [. Thanks for catching. Let me fix this

@gregg-miskelly
Copy link
Contributor

Otherwise LGTM. @DustinCampbell @TheRealPiotrP would either of you like to review as well?

Copy link
Contributor

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks again!

@vishrutshah
Copy link
Contributor Author

Thanks @gregg-miskelly for helping review the changes!

@rchande rchande merged commit cc4016f into dotnet:master Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants