breck7 / scrollsdk

The code for Particles and Parsers, which Scroll is built on.
https://sdk.scroll.pub
383 stars 17 forks source link

build is adding whitespaces on unmodified files. #178

Closed elviejo79 closed 4 months ago

elviejo79 commented 1 year ago

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
breck7 commented 4 months ago

Sorry, when I run npm run build 2x, nothing is changed on the 2nd run. Is this a windows issue?

breck7 commented 4 months ago

Going to close for now but feel free to reopen with more info