Pull version information from package.json, running `npm run build` produces unwanted changes
See original GitHub issueHi @thomasrockhu!
I was going to create a pull request for this, but in my local setup when I run npm i
followed by npm run build
I get many spurious unrelated changes in dist/index.js
, mostly a diff that starts with var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
and goes on from there, many times in the file. I tried this in two separate machines and have had the issue on both… Not sure if your machine setup is different and is picking up a different component version? Anyways, maybe take a look at whether you need to update some component in package.json or similar to ensure generation of dist/index.js
is consistent.
The suggestion I was going to make is:
diff --git a/src/buildExec.ts b/src/buildExec.ts
index edb614f..2dbf0a4 100644
--- a/src/buildExec.ts
+++ b/src/buildExec.ts
@@ -1,7 +1,7 @@
const core = require('@actions/core');
const github = require('@actions/github');
-import VERSION from './version';
+const pjson = require('../package.json');
const context = github.context;
@@ -59,7 +59,7 @@ const buildExec = () => {
'-F',
`${flags}`,
'-Q',
- `github-action-${VERSION}`,
+ `github-action-v${pjson.version}`,
);
const options:any = {};
Which reads the “version” field from package.json, so you could remove src/version.ts
altogether and keep the version string in a single place. (BTW, I found this suggestion in this StackOverflow answer.)
Feel free to push a commit with this change if you like the idea. Or let me know if you manage to figure out if something was missing in package.json to make generation consistent and I can send a PR then.
Cheers! Filipe
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (14 by maintainers)
Top GitHub Comments
Can you try to remove the node_modules folder and run installation again? npm takes into account the shape of the node_modules folder when trying to determine what to install. In other words, it’s behavior is partially determined by node_modules. You want a fresh installation at every point you can get.
Additionally, please update your distribution of both Node.js and npm. v12.18.4 contains unpatched vulnerabilities.