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 --devdir flag. #916

Merged
merged 1 commit into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Command Options
| `--thin=yes` | Enable thin static libraries
| `--arch=$arch` | Set target architecture (e.g. ia32)
| `--tarball=$path` | Get headers from a local tarball
| `--devdir=$path` | SDK download directory (default=~/.node-gyp)
| `--ensure` | Don't reinstall headers if already present
| `--dist-url=$url` | Download header tarball from custom URL
| `--proxy=$url` | Set HTTP proxy for downloading header tarball
Expand Down
15 changes: 15 additions & 0 deletions bin/node-gyp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ process.title = 'node-gyp'

var gyp = require('../')
var log = require('npmlog')
var osenv = require('osenv')
var path = require('path')

/**
* Process and execute the selected commands.
Expand All @@ -20,6 +22,19 @@ var log = require('npmlog')
var prog = gyp()
var completed = false
prog.parseArgv(process.argv)
prog.devDir = prog.opts.devdir

var homeDir = osenv.home()
if (prog.devDir) {
prog.devDir = prog.devDir.replace(/^~/, homeDir)
} else if (homeDir) {
prog.devDir = path.resolve(homeDir, '.node-gyp')
} else {
throw new Error(
"node-gyp requires that the user's home directory is specified " +
"in either of the environmental variables HOME or USERPROFILE. " +
"Overide with: --devdir /path/to/.node-gyp")
}

if (prog.todo.length === 0) {
if (~process.argv.indexOf('-v') || ~process.argv.indexOf('--version')) {
Expand Down
14 changes: 2 additions & 12 deletions lib/node-gyp.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,7 @@ function gyp () {
function Gyp () {
var self = this

// set the dir where node-gyp dev files get installed
// TODO: make this *more* configurable?
// see: https://github.com/nodejs/node-gyp/issues/21
var homeDir = process.env.HOME || process.env.USERPROFILE
if (!homeDir) {
throw new Error(
"node-gyp requires that the user's home directory is specified " +
"in either of the environmental variables HOME or USERPROFILE"
);
}
this.devDir = path.resolve(homeDir, '.node-gyp')

this.devDir = ''
this.commands = {}

commands.forEach(function (command) {
Expand Down Expand Up @@ -92,6 +81,7 @@ proto.configDefs = {
, ensure: Boolean // 'install'
, solution: String // 'build' (windows only)
, proxy: String // 'install'
, devdir: String // everywhere
, nodedir: String // 'configure'
, loglevel: String // everywhere
, python: String // 'configure'
Expand Down