question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to apply applicable options to package.json

See original GitHub issue
  • 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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
maleptcommented, 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) => { /* ... */ });
0reactions
develarcommented, Feb 20, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add option to apply applicable options to package.json #602
As far as I can tell, this would only apply to the version and name options. I think name should modify productName in...
Read more >
package.json - npm Docs
This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just a...
Read more >
Add custom metadata or config to package.json, is it valid?
Yes, you're allowed to add custom entries to package.json . Choose a key name: not already defined (details below); not reserved for future...
Read more >
How To Use Node.js Modules with npm and package.json
The first step will be to create and understand the package.json file. You will then use it to keep track of all the...
Read more >
An Introduction to Package JSON Scripts in Node.js
Lots of Node.js codebases use the package.json file as an ... you can pass options to the command you are using in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found