When injecting multiple files, the final rendering of the inject.js file is corrupted
alert('Test1')
console.log('Test2')
nativefier --inject test1.js --inject test2.js --name Github https://github.com
alert('Test1')
st2')
Version of Nativefier (run nativefier --version): v7.4.1
Version of Node.js (run node --version): v8.5.0
OS: macOS High Sierra 10.13.1
@jplot merci du retour 馃憤. Before I give a try at reproducing the issue, one wording nit: when you say "deteriorated", are you saying Nativefier regressed? (Said differently, did it use to work? If yes, when and any idea when it started mangling data?) Thanks.
@ronjouch No it does not work, from the second file inject it corrupts inject.js
No it does not work, from the second file inject it corrupts inject.js
@jplot I get that, but my question is: has it already worked in an earlier version of Nativefier?
@ronjouch Yes, 7.4.0 and 7.4.1
Still not clear, please make a complete sentence.
does not work on Nativefier v7.4.0 and v7.4.1
I believe the problem as reported is that the user is trying to inject two script files and that just isn't supported. The --inject handler in the build script copies any injected js file to inject.js without any consideration for multiple files.
As to why it's got the strange content rather than just being one file or the other, under the covers it looks like the injection handling functions uses the ncp library to perform file copies and _that_ library uses stream copying, so it's probably overwriting only portions of the file.
Scenario, those two files end with newline characters (\n), it first copies characters 1-21 of the string console.log('Test2')\n and then overwrites characters 1-15 of that with alert('Test1')\n giving you alert('Test1')\nst2')
It looks like the behavior now is that one js file is randomly picked. It would be nice to be able to pick.
It seams like this is still an issue. For me, the last --inject ....js wins, and the first one is ignored.
Most helpful comment
I believe the problem as reported is that the user is trying to inject two script files and that just isn't supported. The
--injecthandler in the build script copies any injected js file toinject.jswithout any consideration for multiple files.As to why it's got the strange content rather than just being one file or the other, under the covers it looks like the injection handling functions uses the ncp library to perform file copies and _that_ library uses stream copying, so it's probably overwriting only portions of the file.
Scenario, those two files end with newline characters (
\n), it first copies characters 1-21 of the stringconsole.log('Test2')\nand then overwrites characters 1-15 of that withalert('Test1')\ngiving youalert('Test1')\nst2')