Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
build: move SDK detection to npm-cli.js
Browse files Browse the repository at this point in the history
This partially reverts commit 64480a5,
removing all the changes to set the NPM_CONFIG_NODEDIR variable.

NPM_CONFIG_NODEDIR is now set in npm-cli.js, this will be necessary
until node-gyp can download all the files needed for node-chakracore
on its own.

This change allows bin/npm to be a symlink again in Unix.

PR-URL: #291
Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
Reviewed-By: Kunal Pathak <kunal.pathak@microsoft.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
  • Loading branch information
joaocgreis authored and kfarnung committed Jun 13, 2017
1 parent 25bdb95 commit 16160c2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 0 additions & 4 deletions deps/chakrashim/npm

This file was deleted.

8 changes: 8 additions & 0 deletions deps/npm/bin/npm-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
return
}

if (!process.env.NPM_CONFIG_NODEDIR) {
if (process.platform === 'win32') {
process.env.NPM_CONFIG_NODEDIR = require('path').join(process.execPath, '..', 'sdk')
} else {
process.env.NPM_CONFIG_NODEDIR = require('path').join(process.execPath, '..', '..')
}
}

process.title = 'npm'

var unsupported = require('../lib/utils/unsupported.js')
Expand Down
10 changes: 8 additions & 2 deletions tools/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ def npm_files(action):
paths = [os.path.join(dirname, basename) for basename in basenames]
action(paths, target_path + dirname[9:] + '/')

# create/remove npm invoke script
action(['deps/chakrashim/npm'], 'bin/npm')
# create/remove symlink
link_path = abspath(install_path, 'bin/npm')
if action == uninstall:
action([link_path], 'bin/npm')
elif action == install:
try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
else:
assert(0) # unhandled action type

def subdir_files(path, dest, action):
ret = {}
Expand Down
6 changes: 0 additions & 6 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,6 @@ copy /Y node.lib node-v%FULLVERSION%-win-%target_arch%\sdk\%config%\ > nul
if errorlevel 1 echo Cannot copy node.lib && goto package_error
copy /Y chakracore.lib node-v%FULLVERSION%-win-%target_arch%\sdk\%config%\ > nul
if errorlevel 1 echo Cannot copy chakracore.lib && goto package_error
set "pkgnpmsh=node-v%FULLVERSION%-win-%target_arch%/npm"
%native_node_exe% -e "var data=fs.readFileSync('%pkgnpmsh%', 'utf8').split('\n');data.splice(-2, 0, 'export NPM_CONFIG_NODEDIR=\"$basedir/sdk\"');fs.writeFileSync('%pkgnpmsh%', data.join('\n'))"
if errorlevel 1 echo Cannot change %pkgnpmsh% && goto package_error
set "pkgnpmcmd=node-v%FULLVERSION%-win-%target_arch%/npm.cmd"
%native_node_exe% -e "var data=fs.readFileSync('%pkgnpmcmd%', 'utf8').split('\n');data.splice(-2, 0, 'SET \"NPM_CONFIG_NODEDIR=%%~dp0\\sdk\"');fs.writeFileSync('%pkgnpmcmd%', data.join('\n'))"
if errorlevel 1 echo Cannot change %pkgnpmcmd% && goto package_error

echo Creating node-v%FULLVERSION%-win-%target_arch%.7z
del node-v%FULLVERSION%-win-%target_arch%.7z > nul 2> nul
Expand Down

0 comments on commit 16160c2

Please sign in to comment.