jtree icon indicating copy to clipboard operation
jtree copied to clipboard

build is adding whitespaces on unmodified files.

Open elviejo79 opened this issue 1 year ago • 0 comments

set -xeuo pipefail IFS=$'\n\t'

build creates invalid files on second run.

on consecutive runs of npm run build it generates invalid files. becaus the files have more spaces.

Steps to reproduce.

clean any previous build of this issue/script

rm -rf build_issue_jtree || true

Create a fresh install of jtree

gh repo clone breck7/jtree build_issue_jtree && cd ./build_issue_jtree && npm install ts-node && npm run cloc && npm run build

As you can see nothing has changed:

git status

Now let's swap the last two lines of projects.tree in order to trigger a rebuild.

input_file="products.tree";
tmp_file="products.temp";
awk 'NR>2{print last_but_one} {last_but_one=last; last=$0} END{print last; print last_but_one}' "${input_file}" > "${tmp_file}" && \
    mv "${tmp_file}" "${input_file}"

Execute build again

npm run build || true
As you can see the build command already throws an error.
But what is it?

Now files have changed (although) they shouldn't have since we haven't done any changes to the contents them selves.

git status

What has changed?

git diff ./products/SandboxApp.browser.js
As you can see it looks as if nothing changed, yet all the lines are marked as different what happned is that now what used to have two spaces now have four!
Even worst the generated files are invalid.

What is the expected result?

the files shouldn't change on successive npm run build

How to automate this bug report?

this issue is valid markdown and valid bash. In order to reproduce it just copy the raw markdown and do:
bash ./build_issue.md.sh

elviejo79 avatar Apr 10 '23 17:04 elviejo79