Open xxxxst opened 1 year ago
6.5.0
windows 7
node v12.16.3 npm v6.14.4 yarn v1.12.1
add code on the first or last line, when reinstall, the code is repeated
init environment
>yarn init >yarn add -D patch-package postinstall-postinstall >yarn add axios@0.21.4
add "scripts": { "postinstall": "patch-package" }, to package.json
"scripts": { "postinstall": "patch-package" },
edit file "node_modules/axios/index.js", add var aaa = 3; to the first line
var aaa = 3;
var aaa = 3; module.exports = require('./lib/axios');
save file and run command:
>yarn patch-package axios
patch-package will then generate the file: axios+0.21.4.patch
diff --git a/node_modules/axios/index.js b/node_modules/axios/index.js index 79dfd09..c995a6f 100644 --- a/node_modules/axios/index.js +++ b/node_modules/axios/index.js @@ -1 +1,2 @@ +var aaa = 3; module.exports = require('./lib/axios'); \ No newline at end of file
then remove directory "node_modules", reinstall package
>yarn install
the new file is (node_modules/axios/index.js)
var aaa = 3; var aaa = 3; module.exports = require('./lib/axios');
You can see that the modified code appears twice, The same problem occurs when code is added at the end
every time you run yarn patch-package
yarn patch-package
a new code var aaa = 3; will be add to the file
I liiked a bit into it, here is what I've found:
npm install
postinstall-postinstall
Seems like postinstall-postinstall makes problems.
version
6.5.0
Environment
windows 7
node v12.16.3 npm v6.14.4 yarn v1.12.1
Current Behavior
add code on the first or last line, when reinstall, the code is repeated
Steps to Reproduce
init environment
add
"scripts": { "postinstall": "patch-package" },
to package.jsonedit file "node_modules/axios/index.js", add
var aaa = 3;
to the first linesave file and run command:
patch-package will then generate the file: axios+0.21.4.patch
then remove directory "node_modules", reinstall package
the new file is (node_modules/axios/index.js)
You can see that the modified code appears twice, The same problem occurs when code is added at the end
every time you run
yarn patch-package
a new code
var aaa = 3;
will be add to the file