Skip to content
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

Add , to json file #14423

Closed
wants to merge 1 commit into from
Closed

Add , to json file #14423

wants to merge 1 commit into from

Conversation

YgorPerez
Copy link
Contributor

Without the comma the json code will fail

Without the comma the json code will fail
@netlify
Copy link

netlify bot commented Mar 22, 2022

✅ Deploy Preview for docsdocker ready!

🔨 Explore the source changes: 4cce9fe

🔍 Inspect the deploy log: https://app.netlify.com/sites/docsdocker/deploys/623940c1862b900008c58a72

😎 Browse the preview: https://deploy-preview-14423--docsdocker.netlify.app

@usha-mandya usha-mandya added the area/get-started Relates to get started and onboarding docs label Mar 25, 2022
@usha-mandya
Copy link
Member

@crazy-max Is there a better way to add a custom script without manually modifying the json file?

@crazy-max
Copy link
Member

@usha-mandya scripts is a map so I think the current assumption to add this script is correct. , "debug": is confusing.

@crazy-max
Copy link
Member

We could also use jq with something like:

jq '.scripts + {"debug": "nodemon --inspect=0.0.0.0:9229 server.js"}' < package.json

But don't think it's worth it.

@thaJeztah
Copy link
Member

@crazy-max yeah, so we were discussing "how can we make this less error-prone"? We can't show the whole package.json because it's generated (and way too large to show) - otherwise we could've shown "this is what your file should look like".

Editing JSON can be error-prone, so I was thinking "perhaps rpm has a command to update it" (something like npm script add --name "debug" --command "the command to run" so that it would just "work"

I guess the best alternative then would be to call out "make sure the JSON is valid after you edit it" (or something along those lines)

@thaJeztah
Copy link
Member

because it's generated (and way too large to show)

Perhaps it's still an option to show just the scripts section of the file (if that section always looks the same) to show what it must look like after editing

@crazy-max
Copy link
Member

Yeah with #14423 (comment) it would look like this in output:

{
  "build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
  "lint": "eslint src/**/*.ts __tests__/**/*.ts",
  "format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
  "test": "jest --coverage",
  "all": "yarn run build && yarn run format && yarn test",
  "debug": "nodemon --inspect=0.0.0.0:9229 server.js"
}

with https://github.com/docker/login-action/blob/master/package.json

@crazy-max
Copy link
Member

Also if someone has npx installed he could:

$ npx npm-add-script \
  -k "debug" \
  -v "nodemon --inspect=0.0.0.0:9229 server.js" \
  --force

@usha-mandya
Copy link
Member

@thaJeztah @crazy-max Thanks for weighing in on this.

@YgorPerez Thanks for the PR. Discussed this PR internally and decided not to go ahead with adding , before debug as it can cause confusion and scripting this would also mean that we are complicating this. Closing this PR here without accepting your changes for this reason. Feel free to continue the conversation after I close.

@usha-mandya usha-mandya closed this Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/get-started Relates to get started and onboarding docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants