lscripts 1.1.0 → 1.3.0
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.
- package/lscripts.js +29 -8
- package/package.json +6 -2
package/lscripts.js
CHANGED
|
@@ -6,23 +6,44 @@ import fs from 'fs'
|
|
|
6
6
|
import { exit } from 'process'
|
|
7
7
|
import { spawn } from 'child_process'
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
|
|
9
|
+
const rootDir = '/'
|
|
10
|
+
|
|
11
|
+
const findPackageJsonInWorkingDirOrParent = (currentDir = './') => {
|
|
12
|
+
if (fs.existsSync(`${currentDir}package.json`)) return fs.readFileSync(`${currentDir}package.json`)
|
|
13
|
+
if (fs.realpathSync(currentDir) === rootDir) return null
|
|
14
|
+
return findPackageJsonInWorkingDirOrParent(`${currentDir}../`)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const getScriptsFromPackageJson = (packageJson) =>
|
|
18
|
+
Object.entries(JSON.parse(packageJson).scripts)
|
|
19
|
+
|
|
20
|
+
const getPackageManagerEngine = (currentDir = './') => {
|
|
21
|
+
if (fs.existsSync(`${currentDir}package-lock.json`)) return 'npm'
|
|
22
|
+
if (fs.existsSync(`${currentDir}yarn.lock`)) return 'yarn'
|
|
23
|
+
if (fs.existsSync(`${currentDir}pnpm-lock.yaml`)) return 'pnpm'
|
|
24
|
+
if (fs.realpathSync(currentDir) === rootDir) return null
|
|
25
|
+
return getPackageManagerEngine((`${currentDir}../`))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const packageJson = findPackageJsonInWorkingDirOrParent()
|
|
29
|
+
|
|
30
|
+
if (!packageJson) {
|
|
31
|
+
console.log('No package.json was found in current directory or parent directories.')
|
|
32
|
+
console.log('Make sure you are in a NodeJS project before running lscripts.')
|
|
33
|
+
exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const scripts = getScriptsFromPackageJson(packageJson)
|
|
14
37
|
|
|
15
38
|
const runner = getPackageManagerEngine()
|
|
16
39
|
|
|
17
40
|
if (!runner) {
|
|
18
41
|
console.log('Please install your dependencies before using lscripts.')
|
|
19
42
|
console.log('lscripts uses the lock file to determine which package manager you are using.')
|
|
20
|
-
console.log('lscripts is currently only compatible with npm and
|
|
43
|
+
console.log('lscripts is currently only compatible with npm, yarn and pnpm.')
|
|
21
44
|
exit(1)
|
|
22
45
|
}
|
|
23
46
|
|
|
24
|
-
const scripts = Object.entries(JSON.parse(fs.readFileSync('./package.json')).scripts)
|
|
25
|
-
|
|
26
47
|
const regex = /^(.+) - /
|
|
27
48
|
|
|
28
49
|
const source = async (_, input) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "lscripts",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "lscripts is a command tool that allows you to list and choose a script from your package.json easely.",
|
|
6
6
|
"main": "lscripts.js",
|
|
7
7
|
"bin": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"package.json"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
|
+
"prepare": "husky"
|
|
16
17
|
},
|
|
17
18
|
"author": "@julesfrn",
|
|
18
19
|
"license": "MIT",
|
|
@@ -29,6 +30,9 @@
|
|
|
29
30
|
"inquirer-autocomplete-prompt": "^3.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
33
|
+
"@commitlint/cli": "^19.8.1",
|
|
34
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
35
|
+
"husky": "^9.1.7",
|
|
32
36
|
"semantic-release": "^24.2.7"
|
|
33
37
|
}
|
|
34
38
|
}
|