You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the nativescript-cli doesn't use the same stringify command within FileSystem.writeJson it removes the newline added by npm-cli commands. This causes package.json to appear modified even when nothing has changed which makes for unneeded commits. For reference, below is the writeJson method within nativescript-cli:
To Reproduce tns create MyApp cd ./MyApp
The package.json file will have an extra newline tns platform update android
The package.json file will NOT have an extra newline
Expected behavior
tns operations should not remove newlines from the end of package.json
Additional context
I am happy to open a pull request to modify the writeJson method so that it uses the stringify-package module (the same one that NPM uses and maintains). I would make it add the newline if the file that is being saved is called package.json only. This way it won't affect any other usage of writeJson. I'd like to discuss this here and will open the pull request if everyone agrees.
The text was updated successfully, but these errors were encountered:
It looks like npm broke out the code that stringifies package.json into the stringify-package module for this exact case. It was done so that other projects could use it to ensure they are stringifying package.json in the same way npm does.
Environment
Describe the bug
By default NPM adds a \n newline to the end of the package.json file when npm saves the package.json file.
The line in npm-cli that calls the module that adds the newline
The module, maintained by npm, that adds the newline (stringify-package)
Since the nativescript-cli doesn't use the same stringify command within FileSystem.writeJson it removes the newline added by npm-cli commands. This causes package.json to appear modified even when nothing has changed which makes for unneeded commits. For reference, below is the writeJson method within nativescript-cli:
nativescript-cli/lib/common/file-system.ts
Line 208 in 6167820
To Reproduce
tns create MyApp
cd ./MyApp
The package.json file will have an extra newline
tns platform update android
The package.json file will NOT have an extra newline
Expected behavior
tns operations should not remove newlines from the end of package.json
Additional context
I am happy to open a pull request to modify the writeJson method so that it uses the stringify-package module (the same one that NPM uses and maintains). I would make it add the newline if the file that is being saved is called package.json only. This way it won't affect any other usage of writeJson. I'd like to discuss this here and will open the pull request if everyone agrees.
The text was updated successfully, but these errors were encountered: