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

--injecting multiple js files mangles them in nativefied app #458

Open
jplot opened this Issue Oct 3, 2017 · 8 comments

Comments

Projects
None yet
4 participants
@jplot

jplot commented Oct 3, 2017

Description

When injecting multiple files, the final rendering of the inject.js file is corrupted

Steps to reproduce issue

test1.js

alert('Test1')

test2.js

console.log('Test2')

Run

nativefier --inject test1.js --inject test2.js --name Github https://github.com

Github.app/Contents/Resources/app/inject/inject.js

alert('Test1')
st2')

Specifications

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

@ronjouch

This comment has been minimized.

Collaborator

ronjouch commented Oct 3, 2017

@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.

@jplot

This comment has been minimized.

jplot commented Oct 4, 2017

@ronjouch No it does not work, from the second file inject it corrupts inject.js

@ronjouch

This comment has been minimized.

Collaborator

ronjouch commented Oct 4, 2017

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?

@jplot

This comment has been minimized.

jplot commented Oct 4, 2017

@ronjouch Yes, 7.4.0 and 7.4.1

@ronjouch

This comment has been minimized.

Collaborator

ronjouch commented Oct 4, 2017

Still not clear, please make a complete sentence.

@jplot

This comment has been minimized.

jplot commented Oct 4, 2017

does not work on Nativefier v7.4.0 and v7.4.1

@ronjouch ronjouch changed the title from Multiple injects deteriorated to --injecting multiple js files mangles them in nativefied app Oct 4, 2017

@ronjouch ronjouch removed the need info label Oct 4, 2017

@zbirkenbuel

This comment has been minimized.

zbirkenbuel commented Jan 24, 2018

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')

@Aidoboy

This comment has been minimized.

Aidoboy commented Jun 18, 2018

It looks like the behavior now is that one js file is randomly picked. It would be nice to be able to pick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment