Skip to content

Instantly share code, notes, and snippets.

@xymopen
Last active March 9, 2017 06:28
Show Gist options
  • Save xymopen/5c909099e056f9d61948a9fc8e8475fd to your computer and use it in GitHub Desktop.
Save xymopen/5c909099e056f9d61948a9fc8e8475fd to your computer and use it in GitHub Desktop.
Set up environment variables for npm to deploy packages for electron.
@echo off
call electron.cmd --version 1>NUL 2>&1
if ERRORLEVEL 1 echo Cannot access Electron executable && goto END
:: Electron's version.
for /f %%i in ( 'call electron.cmd --version' ) do set _tmp=%%i
set npm_config_target=%_tmp:v=%
echo npm_config_target=%npm_config_target%
:: The architecture of Electron, can be ia32 or x64.
set EXECUTABLE="%TEMP%\_getArch.node.js"
echo console.log( process.arch ); > %EXECUTABLE%
echo process.exit(); >> %EXECUTABLE%
for /f %%i in ( 'call electron.cmd %EXECUTABLE%' ) do set _tmp=%%i
set npm_config_arch=%_tmp%
set npm_config_target_arch=%_tmp%
echo npm_config_arch=%npm_config_arch%
echo npm_config_target_arch=%npm_config_target_arch%
del %EXECUTABLE%
set EXECUTABLE=
::# Download headers for Electron.
set npm_config_disturl=https://atom.io/download/electron
:: Tell node-pre-gyp that we are building for Electron.
set npm_config_runtime=electron
:: Tell node-pre-gyp to build module from source code.
set npm_config_build_from_source=true
echo npm_config_disturl=%npm_config_disturl%
echo npm_config_runtime=%npm_config_runtime%
echo npm_config_build_from_source=%npm_config_build_from_source%
:END
set _tmp=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment