@cjser/is-installed-globally 1.0.0-cjser.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // packages/@cjser/is-installed-globally.tmp-26-1778152658447/index.js
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ default: () => index_default
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+ var import_node_fs = __toESM(require("node:fs"), 1);
36
+ var import_node_path = __toESM(require("node:path"), 1);
37
+ var import_node_url = require("node:url");
38
+ var import_global_directory_v4_0_1 = __toESM(require("@cjser/global-directory__v4_0_1"), 1);
39
+ var import_is_path_inside = __toESM(require("@cjser/is-path-inside"), 1);
40
+ var import_meta = {};
41
+ var __dirname = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
42
+ var isInstalledGlobally = (() => {
43
+ try {
44
+ return (0, import_is_path_inside.default)(__dirname, import_global_directory_v4_0_1.default.yarn.packages) || (0, import_is_path_inside.default)(__dirname, import_node_fs.default.realpathSync(import_global_directory_v4_0_1.default.npm.packages));
45
+ } catch {
46
+ return false;
47
+ }
48
+ })();
49
+ var index_default = isInstalledGlobally;
package/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ Check if your package was installed globally.
3
+
4
+ @example
5
+ ```
6
+ import isInstalledGlobally from '@cjser/is-installed-globally';
7
+
8
+ // With `npm install your-package`
9
+ console.log(isInstalledGlobally);
10
+ //=> false
11
+
12
+ // With `npm install --global your-package`
13
+ console.log(isInstalledGlobally);
14
+ //=> true
15
+ ```
16
+ */
17
+ declare const isInstalledGlobally: boolean;
18
+
19
+ export default isInstalledGlobally;
package/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import {fileURLToPath} from 'node:url';
4
+ import globalDirectory from '@cjser/global-directory__v4_0_1';
5
+ import isPathInside from '@cjser/is-path-inside';
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+
9
+ const isInstalledGlobally = (() => {
10
+ try {
11
+ return (
12
+ isPathInside(__dirname, globalDirectory.yarn.packages)
13
+ || isPathInside(__dirname, fs.realpathSync(globalDirectory.npm.packages))
14
+ );
15
+ } catch {
16
+ return false;
17
+ }
18
+ })();
19
+
20
+ export default isInstalledGlobally;
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@cjser/is-installed-globally",
3
+ "version": "1.0.0-cjser.2",
4
+ "description": "Check if your package was installed globally",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://code.moenext.com/3rdeye/cjser.git"
9
+ },
10
+ "funding": "https://github.com/sponsors/sindresorhus",
11
+ "author": {
12
+ "name": "Sindre Sorhus",
13
+ "email": "sindresorhus@gmail.com",
14
+ "url": "https://sindresorhus.com"
15
+ },
16
+ "type": "module",
17
+ "exports": {
18
+ "types": "./index.d.ts",
19
+ "require": "./dist-cjser/index.cjs",
20
+ "default": "./index.js"
21
+ },
22
+ "sideEffects": false,
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "scripts": {
27
+ "test": "xo && ava && tsd"
28
+ },
29
+ "files": [
30
+ "index.js",
31
+ "index.d.ts",
32
+ "dist-cjser"
33
+ ],
34
+ "keywords": [
35
+ "global",
36
+ "package",
37
+ "globally",
38
+ "module",
39
+ "install",
40
+ "installed",
41
+ "npm",
42
+ "yarn",
43
+ "is",
44
+ "check",
45
+ "detect",
46
+ "local",
47
+ "locally",
48
+ "cli",
49
+ "bin",
50
+ "binary"
51
+ ],
52
+ "dependencies": {
53
+ "@cjser/global-directory__v4_0_1": "4.0.1-cjser.2",
54
+ "@cjser/is-path-inside": "4.0.0-cjser.2"
55
+ },
56
+ "devDependencies": {
57
+ "ava": "^5.3.1",
58
+ "cpy": "^8",
59
+ "del": "^7.1.0",
60
+ "execa": "^8.0.1",
61
+ "make-dir": "^4.0.0",
62
+ "tsd": "^0.29.0",
63
+ "xo": "^0.56.0"
64
+ },
65
+ "types": "./index.d.ts",
66
+ "main": "./dist-cjser/index.cjs",
67
+ "cjser": {
68
+ "sourceVersion": "1.0.0",
69
+ "cjserVersion": 2,
70
+ "original": {
71
+ "name": "is-installed-globally",
72
+ "version": "1.0.0",
73
+ "exports": {
74
+ "types": "./index.d.ts",
75
+ "default": "./index.js"
76
+ },
77
+ "repository": "sindresorhus/is-installed-globally",
78
+ "dependencies": {
79
+ "global-directory": "^4.0.1",
80
+ "is-path-inside": "^4.0.0"
81
+ },
82
+ "files": [
83
+ "index.js",
84
+ "index.d.ts"
85
+ ],
86
+ "scripts": {
87
+ "test": "xo && ava && tsd"
88
+ }
89
+ }
90
+ }
91
+ }
package/readme.md ADDED
@@ -0,0 +1,36 @@
1
+ # is-installed-globally
2
+
3
+ > Check if your package was installed globally
4
+
5
+ Can be useful if your CLI needs different behavior when installed globally and locally.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install is-installed-globally
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ import isInstalledGlobally from 'is-installed-globally';
17
+
18
+ // With `npm install your-package`
19
+ console.log(isInstalledGlobally);
20
+ //=> false
21
+
22
+ // With `npm install --global your-package`
23
+ console.log(isInstalledGlobally);
24
+ //=> true
25
+ ```
26
+
27
+ ## Related
28
+
29
+ - [import-global](https://github.com/sindresorhus/import-global) - Import a globally installed module
30
+ - [resolve-global](https://github.com/sindresorhus/resolve-global) - Resolve the path of a globally installed module
31
+ - [global-directory](https://github.com/sindresorhus/global-directory) - Get the directory of globally installed packages and binaries
32
+
33
+ ## cjser
34
+
35
+ This package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
36
+ Original repository: https://github.com/sindresorhus/is-installed-globally