-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 8, add TypeScript definition (#2)
- Loading branch information
1 parent
b898cd4
commit 9bb3d61
Showing
10 changed files
with
116 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '6' | ||
- '4' | ||
- '12' | ||
- '10' | ||
- '8' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
Check if your package was installed globally. | ||
@example | ||
``` | ||
import isInstalledGlobally = require('is-installed-globally'); | ||
// With `npm install your-package` | ||
console.log(isInstalledGlobally); | ||
//=> false | ||
// With `npm install --global your-package` | ||
console.log(isInstalledGlobally); | ||
//=> true | ||
``` | ||
*/ | ||
declare const isInstalledGlobally: boolean; | ||
|
||
export = isInstalledGlobally; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {expectType} from 'tsd'; | ||
import isInstalledGlobally = require('.'); | ||
|
||
expectType<boolean>(isInstalledGlobally); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,53 @@ | ||
{ | ||
"name": "is-installed-globally", | ||
"version": "0.1.0", | ||
"description": "Check if your package was installed globally", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-installed-globally", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"global", | ||
"package", | ||
"globally", | ||
"module", | ||
"install", | ||
"installed", | ||
"npm", | ||
"yarn", | ||
"is", | ||
"check", | ||
"detect", | ||
"local", | ||
"locally", | ||
"cli", | ||
"bin", | ||
"binary" | ||
], | ||
"dependencies": { | ||
"global-dirs": "^0.1.0", | ||
"is-path-inside": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"execa": "^0.7.0", | ||
"xo": "*" | ||
} | ||
"name": "is-installed-globally", | ||
"version": "0.1.0", | ||
"description": "Check if your package was installed globally", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-installed-globally", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"global", | ||
"package", | ||
"globally", | ||
"module", | ||
"install", | ||
"installed", | ||
"npm", | ||
"yarn", | ||
"is", | ||
"check", | ||
"detect", | ||
"local", | ||
"locally", | ||
"cli", | ||
"bin", | ||
"binary" | ||
], | ||
"dependencies": { | ||
"global-dirs": "^0.1.1", | ||
"is-path-inside": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"cpy": "^7.2.0", | ||
"del": "^4.1.0", | ||
"execa": "^1.0.0", | ||
"make-dir": "^3.0.0", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,46 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import execa from 'execa'; | ||
import m from '.'; | ||
import globalDirs from 'global-dirs'; | ||
import del from 'del'; | ||
import makeDir from 'make-dir'; | ||
import cpy from 'cpy'; | ||
/* eslint-disable import/extensions */ | ||
import packageJson from './package.json'; | ||
import fixturePackageJson from './fixture/package.json'; | ||
/* eslint-enable import/extensions */ | ||
import isInstalledGlobally from '.'; | ||
|
||
test('local', t => { | ||
t.false(m); | ||
t.false(isInstalledGlobally); | ||
}); | ||
|
||
test('global', async t => { | ||
const npm = args => execa('npm', args, {cwd: 'fixture'}); | ||
await npm(['install', '--global', '.']); | ||
|
||
const fixtureGlobalPath = path.join( | ||
globalDirs.npm.packages, | ||
fixturePackageJson.name | ||
); | ||
const isInstalledGloballyGlobalPathInFixture = path.join( | ||
fixtureGlobalPath, | ||
'node_modules', | ||
packageJson.name | ||
); | ||
await del(fixtureGlobalPath, {force: true}); | ||
await makeDir(isInstalledGloballyGlobalPathInFixture); | ||
await cpy(['./**/*'], fixtureGlobalPath, { | ||
cwd: 'fixture', | ||
followSymlinkedDirectories: false, | ||
parents: true | ||
}); | ||
await cpy(['./**/*'], isInstalledGloballyGlobalPathInFixture, { | ||
followSymlinkedDirectories: false, | ||
parents: true | ||
}); | ||
|
||
t.is(await execa.stdout('is-installed-globally-fixture'), 'true'); | ||
|
||
await npm(['uninstall', '--global', '.']); | ||
await del(fixtureGlobalPath, {force: true}); | ||
}); |