1
1
var path = require ( 'path' ) ;
2
2
var fs = require ( 'fs' ) ;
3
+ var spawn = require ( 'child_process' ) . spawn ;
3
4
4
5
var falafel = require ( 'falafel' ) ;
5
6
var gzipSize = require ( 'gzip-size' ) ;
@@ -10,6 +11,7 @@ var constants = require('./util/constants');
10
11
var pkg = require ( '../package.json' ) ;
11
12
12
13
var pathDistREADME = path . join ( constants . pathToDist , 'README.md' ) ;
14
+ var pathDistNpmLs = path . join ( constants . pathToDist , 'npm-ls.json' ) ;
13
15
var cdnRoot = 'https://cdn.plot.ly/plotly-' ;
14
16
var coreModules = [ 'scatter' ] ;
15
17
@@ -18,15 +20,25 @@ var JS = '.js';
18
20
var MINJS = '.min.js' ;
19
21
20
22
// main
21
- var content = getContent ( ) ;
22
- common . writeFile ( pathDistREADME , content . join ( '\n' ) ) ;
23
+ writeNpmLs ( ) ;
24
+ common . writeFile ( pathDistREADME , getReadMeContent ( ) ) ;
23
25
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 ( ) {
25
36
return [ ]
26
37
. concat ( getInfoContent ( ) )
27
38
. concat ( getMainBundleInfo ( ) )
28
39
. concat ( getPartialBundleInfo ( ) )
29
- . concat ( getFooter ( ) ) ;
40
+ . concat ( getFooter ( ) )
41
+ . join ( '\n' ) ;
30
42
}
31
43
32
44
// general info about distributed files
0 commit comments