@pnpm/config
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -8,3 +8,3 @@ export declare const types: any; | ||
}; | ||
}) => any; | ||
}) => Promise<any>; | ||
export default _default; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -7,2 +15,8 @@ const camelcase = require("camelcase"); | ||
const path = require("path"); | ||
const whichcb = require("which"); | ||
function which(cmd) { | ||
return new Promise((resolve, reject) => { | ||
whichcb(cmd, (err, resolvedPath) => err ? reject(err) : resolve(resolvedPath)); | ||
}); | ||
} | ||
exports.types = Object.assign({ | ||
@@ -36,6 +50,18 @@ 'background': Boolean, | ||
}, npmTypes.types); | ||
exports.default = (opts) => { | ||
exports.default = (opts) => __awaiter(this, void 0, void 0, function* () { | ||
const packageManager = opts && opts.packageManager || { name: 'pnpm', version: 'undefined' }; | ||
const cliArgs = opts && opts.cliArgs || {}; | ||
// This is what npm does as well, overriding process.execPath with the resolved location of Node. | ||
// The value of process.execPath is changed only for the duration of config initialization. | ||
// Otherwise, npmConfig.globalPrefix would sometimes have the bad location. | ||
const originalExecPath = process.execPath; | ||
try { | ||
const node = yield which(process.argv[0]); | ||
if (node.toUpperCase() !== process.execPath.toUpperCase()) { | ||
process.execPath = node; | ||
} | ||
} | ||
catch (err) { } // tslint:disable-line:no-empty | ||
const npmConfig = loadNpmConf(); | ||
process.execPath = originalExecPath; | ||
if (!cliArgs['user-agent']) { | ||
@@ -78,3 +104,3 @@ cliArgs['user-agent'] = `${packageManager.name}/${packageManager.version} npm/? node/${process.version} ${process.platform} ${process.arch}`; | ||
return pnpmConfig; | ||
}; | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@pnpm/config", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Gets configs for pnpm", | ||
@@ -36,4 +36,6 @@ "main": "lib/index.js", | ||
"@types/node": "^9.4.6", | ||
"@types/which": "^1.3.1", | ||
"camelcase": "^4.1.0", | ||
"npm-conf": "^1.1.3" | ||
"npm-conf": "^1.1.3", | ||
"which": "^1.3.0" | ||
}, | ||
@@ -40,0 +42,0 @@ "devDependencies": { |
@@ -20,3 +20,3 @@ # @pnpm/config | ||
const pnpmConfigs = getConfigs() | ||
getConfigs().then(pnpmConfigs => console.log(pnpmConfigs)) | ||
``` | ||
@@ -23,0 +23,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11430
111
6
+ Added@types/which@^1.3.1
+ Addedwhich@^1.3.0
+ Added@types/which@1.3.2(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedwhich@1.3.1(transitive)