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

Add option to apply applicable options to package.json #602

Closed
3 tasks done
ItsHarper opened this issue Feb 20, 2017 · 5 comments
Closed
3 tasks done

Add option to apply applicable options to package.json #602

ItsHarper opened this issue Feb 20, 2017 · 5 comments
Labels
enhancement Feature request wontfix ❌ Maintainers have decided not to pursue this issue

Comments

@ItsHarper
Copy link

ItsHarper commented Feb 20, 2017

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

For instance, setting the app-version option would not only change the "ProductVersion metadata property on Windows, and CFBundleShortVersionString on OS X", but would also change version in the packaged app's package.json. This way, accessing app.version from Electron will return the version passed to electron-packager, and not the original version.

As far as I can tell, this would only apply to the version and name options. I think name should modify productName in package.json.

IMHO, this should eventually be made the default behavior, but that would require a major version change.

If this sounds good, I might go ahead and work on a PR for this.

@malept
Copy link
Member

malept commented Feb 20, 2017

Just so I'm clear about the feature you're requesting, you could like Electron Packager to update the version field of the Electron app's package.json if, for example, --app-version=1.2.3 is specified on the command line? If this is accurate, what is the use case for this feature?

@ItsHarper
Copy link
Author

Yes, but it would only update the version of package.json located in the temp directory for packaging. The main source code would be unchanged.

My use case for this feature is to have a script that uses electron-packager to make a test version of the app. The electron-packager name option would include the word "test". The packaged test app would then be able to check for the word test and modify its behavior as discussed here.

@malept malept added enhancement Feature request wontfix ❌ Maintainers have decided not to pursue this issue labels Feb 20, 2017
@malept
Copy link
Member

malept commented Feb 20, 2017

I'm not inclined to add this functionality to Electron Packager, partly because I don't see a broader use case for it, and partly because I think it will make the code base messier than it already is.

However, you can implement it for your app by using an afterCopy hook with the packager API:

const packager = require('electron-packager');

const packagerOptions = {
  // ...
  afterCopy: (buildPath, electronVersion, platform, arch, callback) => {
    // read package.json from buildPath
    // modify deserialized package.json
    // write new package.json contents
    callback();
  }
  // ...
};

packager(packagerOptions, (err, appPaths) => { /* ... */ });

@malept malept closed this as completed Feb 20, 2017
@ItsHarper
Copy link
Author

OK, thanks for reminding me about afterCopy. That should do nicely.

@develar
Copy link
Contributor

develar commented Feb 20, 2017

electron-builder for such use case supports --extraMetadata — ability to inject/modify package.json (e.g. electron-userland/electron-builder#639 (comment)). Because in general such options should be inferred from package.json, not vice versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request wontfix ❌ Maintainers have decided not to pursue this issue
Projects
None yet
Development

No branches or pull requests

3 participants