Permalink
Browse files

refactor: use is-windows package

For detecting Windows OS, use the is-windows package.
  • Loading branch information...
1 parent af4d86b commit 1c00eb025e96ff58a493fc8dde5f40819205df93 @zkochan zkochan committed Jan 9, 2017
Showing with 14 additions and 9 deletions.
  1. +1 −0 package.json
  2. +0 −1 src/env.ts
  3. +4 −2 src/install/linkBins.ts
  4. +4 −3 test/install.ts
  5. +0 −2 test/support/isExecutable.ts
  6. +0 −1 tsconfig.json
  7. +5 −0 typings/local.d.ts
View
@@ -46,6 +46,7 @@
"find-up": "2.1.0",
"is-ci": "1.0.10",
"is-retry-allowed": "1.1.0",
+ "is-windows": "1.0.0",
"js-yaml": "3.7.0",
"json2yaml": "1.1.0",
"link-dir": "1.0.3",
View
@@ -1 +0,0 @@
-export const isWindows = process.platform === 'win32'
@@ -6,10 +6,12 @@ import mkdirp from '../fs/mkdirp'
import requireJson from '../fs/requireJson'
import getPkgDirs from '../fs/getPkgDirs'
import binify from '../binify'
-import {isWindows} from '../env'
+import isWindows = require('is-windows')
import cmdShim = require('@zkochan/cmd-shim')
import {Package} from '../types'
+const IS_WINDOWS = isWindows()
+
export default async function linkAllBins (modules: string, preserveSymlinks: boolean) {
const pkgDirs = await getPkgDirs(modules)
return Promise.all(pkgDirs.map((pkgDir: string) => linkPkgBins(modules, pkgDir, preserveSymlinks)))
@@ -53,7 +55,7 @@ export async function linkPkgBins (modules: string, target: string, preserveSyml
}
const relTargetPath = normalizePath(path.join('..', pkg.name, actualBin))
- if (isWindows) {
+ if (IS_WINDOWS) {
const proxyFilePath = path.join(binDir, `${bin}.proxy`)
await fs.writeFile(proxyFilePath, `#!/usr/bin/env node\r\nrequire("${relTargetPath}")`, 'utf8')
return cmdShim(proxyFilePath, externalBinPath, {preserveSymlinks})
View
@@ -19,11 +19,12 @@ import testDefaults from './support/testDefaults'
import exists = require('exists-file')
import {pathToLocalPkg, local} from './support/localPkg'
import {sync as execPnpmSync} from './support/execPnpm'
+import isWindows = require('is-windows')
-const isWindows = process.platform === 'win32'
+const IS_WINDOWS = isWindows()
const preserveSymlinks = semver.satisfies(process.version, '>=6.3.0')
-if (!caw() && !isWindows) {
+if (!caw() && !IS_WINDOWS) {
process.env.VCR_MODE = 'cache'
}
@@ -304,7 +305,7 @@ test('bundleDependencies (pkg-with-bundled-dependencies@1.0.0)', async function
test('compiled modules (ursa@0.9.1)', async function (t) {
// TODO: fix this for Node.js v7
- if (!isCI || isWindows || semver.satisfies(process.version, '>=7.0.0')) {
+ if (!isCI || IS_WINDOWS || semver.satisfies(process.version, '>=7.0.0')) {
t.skip('runs only on CI')
return
}
@@ -4,8 +4,6 @@ import {Test} from 'tape'
import semver = require('semver')
import {Stats} from 'fs'
-const isWindows = process.platform === 'win32'
-
export default async function isExecutable (t: Test, filePath: string) {
t.ok(isexe(filePath), filePath + ' is executable')
}
View
@@ -45,7 +45,6 @@
"src/cmd/uninstall.ts",
"src/cmd/update.ts",
"src/debug.ts",
- "src/env.ts",
"src/err.ts",
"src/fileLogger.ts",
"src/fs/expandTilde.ts",
View
@@ -212,3 +212,8 @@ declare module 'pnpm-install-checks' {
const anything: any;
export = anything;
}
+
+declare module 'is-windows' {
+ function isWindows(): boolean;
+ export = isWindows;
+}

0 comments on commit 1c00eb0

Please sign in to comment.