Skip to content

Commit b5da479

Browse files
committed
feat: always write full JSON output into tmp path
1 parent 7c5baeb commit b5da479

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bin/detect-node-support

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22

33
'use strict';
44

5+
const Debug = require('debug');
6+
const Fs = require('fs');
57
const Minimist = require('minimist');
8+
const Tmp = require('tmp');
69
const Util = require('util');
710

811
const NodeSupport = require('..');
912

1013
const internals = {};
1114

15+
16+
internals.log = Debug('detect-node-support');
17+
18+
1219
internals.help = () => {
1320

1421
return `
@@ -40,11 +47,16 @@ exports.main = async ({ _: [what], deps, deep, dev, json }) => {
4047

4148
const result = await NodeSupport.detect(what, { deps, deep, dev });
4249

50+
const jsonOutput = JSON.stringify(result, null, ' ');
51+
const tmpFile = Tmp.fileSync({ postfix: '.json' });
52+
Fs.writeFileSync(tmpFile.name, jsonOutput);
53+
4354
if (json) {
44-
console.log(JSON.stringify(result, null, ' '));
55+
console.log(jsonOutput);
4556
}
4657
else {
4758
console.log(Util.inspect(result, false, null, true));
59+
console.log(`Full output available in ${tmpFile.name}`);
4860
}
4961
};
5062

0 commit comments

Comments
 (0)