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

#431: fixed build command #448

Merged
merged 7 commits into from
Aug 27, 2020
Merged

#431: fixed build command #448

merged 7 commits into from
Aug 27, 2020

Conversation

hohwille
Copy link
Member

Fix for #431

@hohwille hohwille added commandlet related to commandlets (scripts/command/*) enhancement New feature or request javascript related to JavaScript tooling (node, npm, ng, etc.) SCM software-configuration-management (github actions, internal processes, git or github utilization) scripts related to shell scripts (bash and CMD) labels Aug 24, 2020
@hohwille hohwille linked an issue Aug 24, 2020 that may be closed by this pull request
@hohwille
Copy link
Member Author

As discussed offline there have been issues when node_modules have not been present. This was previously silently adding install as goal to the build-tool. However, unlike tools like mvn for npm or yarn this was entirely incorrect as

npm install build

means something totally different than

npm install
npm build

In JS build tools goals can also be followed by parameters such as

npm add «pacakge»

Therefore npm install build is thinking that the dependency build should be installed and even adds this to the package.json as dependency leading to silly results. It took me while to understand these worlds of JS. Would have been easier if some domain expert had created the commandlets initially.

@hohwille hohwille added this to the release:2020.08.001 milestone Aug 25, 2020
@hohwille
Copy link
Member Author

OK, for some odd reason tr '\n' '§' is not working in git-bash (on windows).
Therefore we had to use sed magic. To avoid redundancy of this kind of tricky detection inside package.json, I moved it to functions and share it between npm and yarn commandlets.

Also I found and fixed another small bug that debug option (-d or --debug) was not passed by doDevonCommand. Therefore without this fix devon build -d was not printing debug info while devon yarn -d build did. With the fix both behave the same.

@hohwille hohwille merged commit bea90ea into devonfw:master Aug 27, 2020
@markusschuh
Copy link
Member

Introducing a non-ASCII char like '§' into the stream has an influence on the "binary detection" logic built into grep - and this is dependent on the shell environment, since the intention of this check is to avoid output of binary as potentially non-printable chars inside grep output. So an additional "-a" option (treat all files as ASCII text) to grep would harden the code more against such environment differences.

But since both npm and yarn have node as prerequisite - hence a more powerful scripting language is available - it might make more sense to do the check with javascript:

node -e "process.exit(require('./package.json').scripts.hasOwnProperty('build'));"

Tested successfully also with an a bit older node 10.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commandlet related to commandlets (scripts/command/*) enhancement New feature or request javascript related to JavaScript tooling (node, npm, ng, etc.) SCM software-configuration-management (github actions, internal processes, git or github utilization) scripts related to shell scripts (bash and CMD)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

devon build command not working correct for yarn or npm
2 participants