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

Get or Specify Final Build exe or dmg file names #899

Closed
aesalazar opened this issue Nov 11, 2016 · 7 comments · May be fixed by qcif/data-curator#563
Closed

Get or Specify Final Build exe or dmg file names #899

aesalazar opened this issue Nov 11, 2016 · 7 comments · May be fixed by qcif/data-curator#563
Labels

Comments

@aesalazar
Copy link

  • Version: 7.24.1
  • Target: Windows and Mac

Doing programmatic builds in JavaScript. I would like to be able to get the output file name somehow. I can concatenate the properties but that is assumption based and would rather know definitely what the final file_name.exe is. It would be nice to actually specify it somehow. I posted a question on StackOverflow: http://stackoverflow.com/questions/40549421/retrieve-or-specify-output-file-name-in-electron-builder

Thanks
Ernie

@develar
Copy link
Member

develar commented Nov 11, 2016

For what do you need output file name?

You can use packagerdirectly and listen artifactCreated event. Please see https://github.com/electron-userland/electron-builder/blob/master/src/builder.ts method build implementation.

@aesalazar
Copy link
Author

aesalazar commented Nov 11, 2016

Consider this:

//Install page for Electron Application
router.get('/electron', function(req, res, next){
    const promise = electronBuilder
        .buildPromise()
        .then(() => {
            const file = electronBuilder.outputFilename;
            const data = fs.readFileSync(`${electronBuilder.outputPath}/${file}`);

            res.setHeader('Content-Disposition', `attachment; filename="${file}"`);

            if(file.substr(file.length - 3) === "exe")
                res.setHeader('Content-type', 'application/exe, application/octet-stream');
            else if (file.substr(file.length - 3) === "dmg")
                res.setHeader('Content-type', 'application/dmg, application/octet-stream');

            res.send(data);
        }).catch((error) => {
            console.error(error);
        });
});

What I am doing is calling the builder trigger by the user, say, clicking a Download button. After the builder is done I want to send the file back over the response. I do that by recreating the file name like this inside electronBuilder and exposing it:

//Have to recreate output file path
let outputPath = devMetadata.directories.output;
let outputFilename = `${devMetadata.build.productName} Setup ${packagejson.version}`;

if (Platform.current().name === "windows")
    outputFilename += ".exe";
else if(Platform.current().name === "mac")
    outputFilename += ".dmg";

I would be much more comfortable getting the file name directly from the source (i.e. builder) rather then assuming the format.

If I can actually specify the final file name as an input parameter in, say, devMetadata that would be even better but not necessary.

@develar
Copy link
Member

develar commented Nov 11, 2016

builder.buld currently returns Promise<void> and it is not useful. Will be improved.

@aesalazar
Copy link
Author

That would be great if it is some kind of pass argument. Thanks for the help!

Ernie

@develar
Copy link
Member

develar commented Nov 12, 2016

List of artifacts is returned.

screen shot 2016-11-12 at 18 53 41

@develar develar changed the title Get or Specify Final Build exe or dmg file names. Get or Specify Final Build exe or dmg file names Nov 12, 2016
@aesalazar
Copy link
Author

Works great, thanks for adding it!

@aesalazar
Copy link
Author

I tried to test out my app in Unbutu (was using windows before) and get an error during npm install:

TypeError: Cannot read property 'npmArgs' of undefined
    at computeExtraArgs (/home/user/git/NodeElectronOpenFinWebPerformance/node_modules/electron-
builder/src/yarn.ts:31:24)
    at /home/user/git/NodeElectronOpenFinWebPerformance/node_modules/electron-builder/src/yarn.t
s:9:16
    at next (native)
From previous event:
    at installOrRebuild (/home/user/git/NodeElectronOpenFinWebPerformance/node_modules/electron-
builder/out/yarn.js:33:21)
    at /home/user/git/NodeElectronOpenFinWebPerformance/node_modules/electron-builder/src/instal
l-app-deps.ts:29:2
    at next (native)
From previous event:
    at main (/home/user/git/NodeElectronOpenFinWebPerformance/node_modules/electron-builder/out/
install-app-deps.js:27:21)
    at Object.<anonymous> (/home/user/git/NodeElectronOpenFinWebPerformance/node_modules/electro
n-builder/out/install-app-deps.js:73:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

Let me know if you need any more details on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants