-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathglobalModule.js
More file actions
35 lines (30 loc) · 974 Bytes
/
Copy pathglobalModule.js
File metadata and controls
35 lines (30 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
const fs = require('fs')
const { join } = require('path')
var SecureSecret = require('./index.js')
let vIndex = -1
const INSTALLED_VERSION = JSON.parse(fs.readFileSync(join(__dirname, "package.json")))["version"]
const MAJOR_VERSION = Number(INSTALLED_VERSION.split(".")[0])
if (["--version", "-v", "-V"].includes(process.argv[2])) {
console.log(`Installed SecureSecret Version: ${INSTALLED_VERSION}`)
process.exit()
}
const version = (process.argv.find((arg, index) => {
if (/@v\d/.test(arg.toLowerCase())) {
vIndex = index
return true
}
return false
}))
if (version) {
const v = version.replace("@", "").replace("v", "V")
if (!SecureSecret[v]) {
console.error(`SecureSecret${version} not exists.`);
process.exit();
}
console.warn(`Using SecureSecret${version}.`)
process.argv.splice(vIndex,1)
SecureSecret[v].cli()
} else {
SecureSecret[`V${MAJOR_VERSION}`].cli();
}