Skip to content

Commit c60b265

Browse files
committed
tasks: log npm ls --json --only prod during stats script
- to log exactly what package version used when bundling dist files - output file is dist/npm-ls.json and will be checked in during `npm version`
1 parent 3744dbc commit c60b265

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tasks/stats.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var path = require('path');
22
var fs = require('fs');
3+
var spawn = require('child_process').spawn;
34

45
var falafel = require('falafel');
56
var gzipSize = require('gzip-size');
@@ -10,6 +11,7 @@ var constants = require('./util/constants');
1011
var pkg = require('../package.json');
1112

1213
var pathDistREADME = path.join(constants.pathToDist, 'README.md');
14+
var pathDistNpmLs = path.join(constants.pathToDist, 'npm-ls.json');
1315
var cdnRoot = 'https://cdn.plot.ly/plotly-';
1416
var coreModules = ['scatter'];
1517

@@ -18,15 +20,25 @@ var JS = '.js';
1820
var MINJS = '.min.js';
1921

2022
// main
21-
var content = getContent();
22-
common.writeFile(pathDistREADME, content.join('\n'));
23+
writeNpmLs();
24+
common.writeFile(pathDistREADME, getReadMeContent());
2325

24-
function getContent() {
26+
function writeNpmLs() {
27+
if(common.doesFileExist(pathDistNpmLs)) fs.unlinkSync(pathDistNpmLs);
28+
29+
var ws = fs.createWriteStream(pathDistNpmLs, { flags: 'a' });
30+
var proc = spawn('npm', ['ls', '--json', '--only', 'prod']);
31+
32+
proc.stdout.pipe(ws);
33+
}
34+
35+
function getReadMeContent() {
2536
return []
2637
.concat(getInfoContent())
2738
.concat(getMainBundleInfo())
2839
.concat(getPartialBundleInfo())
29-
.concat(getFooter());
40+
.concat(getFooter())
41+
.join('\n');
3042
}
3143

3244
// general info about distributed files

0 commit comments

Comments
 (0)