1 | #!/usr/bin/env node
|
2 | 'use strict'
|
3 | const commandLineArgs = require('../')
|
4 | const os = require('os')
|
5 | const fs = require('fs')
|
6 | const path = require('path')
|
7 |
|
8 | const tmpPath = path.join(os.tmpdir(), Date.now() + '-cla.js')
|
9 |
|
10 | process.stdin
|
11 | .pipe(fs.createWriteStream(tmpPath))
|
12 | .on('close', parseCla)
|
13 |
|
14 | function parseCla () {
|
15 | const cliOptions = require(tmpPath)
|
16 | fs.unlinkSync(tmpPath)
|
17 |
|
18 | try {
|
19 | console.log(commandLineArgs(cliOptions))
|
20 | } catch (err) {
|
21 | console.error(err.message)
|
22 | process.exitCode = 1
|
23 | }
|
24 | }
|