-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopt.js
More file actions
executable file
·19 lines (19 loc) · 898 Bytes
/
opt.js
File metadata and controls
executable file
·19 lines (19 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict'
const pck = require('./package.json')
const { readFileSync, existsSync } = require('fs')
const { resolve, join } = require('path')
module.exports = options => {
const opto = [{ arg: ['v', 'version'], out: pck.version, exit: 0 }, { arg: ['h', 'help'], out: readFileSync(join(__dirname, './assets/man/help.man'), 'utf8'), exit: 0 }, { arg: ['i', 'issue'], out: `\n Issues at ${pck.bugs.url} \n `, exit: 0 }, { arg: ['d', 'docs'], out: `\n Docs at ${pck.homepage} \n `, exit: 0 }]
opto.forEach(aro => {
if (options[aro.arg[0]] || options[aro.arg[1]]) {
console.log(aro.out)
process.exit(aro.exit)
}
})
if (existsSync(resolve(options.s || options.save || './'))) {
return {
path: resolve(options.s || options.save || './'),
thanksMsg: (options.r || options.remove) || false
}
} else throw new Error('Enter a valid path')
}