bin: follow XDG OS conventions for storing data

PR-URL: https://github.com/nodejs/node-gyp/pull/1570
Fixes: https://github.com/nodejs/node-gyp/pull/175
Fixes: https://github.com/nodejs/node-gyp/pull/1124
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
Selwyn 2018-10-13 15:12:15 +02:00 committed by Rod Vagg
parent 8098ebdeb4
commit 8a83972743
No known key found for this signature in database
GPG key ID: C273792F7D83545D
3 changed files with 4 additions and 3 deletions

View file

@ -170,7 +170,7 @@ Some additional resources for addons and writing `gyp` files:
| `--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 is `~/.node-gyp`)
| `--devdir=$path` | SDK download directory (default is OS cache directory)
| `--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

View file

@ -2,10 +2,10 @@
process.title = 'node-gyp'
var envPaths = require('env-paths')
var gyp = require('../')
var log = require('npmlog')
var os = require('os')
var path = require('path')
/**
* Process and execute the selected commands.
@ -20,7 +20,7 @@ var homeDir = os.homedir()
if (prog.devDir) {
prog.devDir = prog.devDir.replace(/^~/, homeDir)
} else if (homeDir) {
prog.devDir = path.resolve(homeDir, '.node-gyp')
prog.devDir = envPaths('node-gyp', { suffix: '' }).cache
} else {
throw new Error(
"node-gyp requires that the user's home directory is specified " +

View file

@ -22,6 +22,7 @@
"bin": "./bin/node-gyp.js",
"main": "./lib/node-gyp.js",
"dependencies": {
"env-paths": "^1.0.0",
"glob": "^7.0.3",
"graceful-fs": "^4.1.2",
"mkdirp": "^0.5.0",