UNPKG

515 BJavaScriptView Raw
1#!/usr/bin/env node
2'use strict'
3const commandLineArgs = require('../')
4const os = require('os')
5const fs = require('fs')
6const path = require('path')
7
8const tmpPath = path.join(os.tmpdir(), Date.now() + '-cla.js')
9
10process.stdin
11 .pipe(fs.createWriteStream(tmpPath))
12 .on('close', parseCla)
13
14function 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}