@@ -10,10 +10,10 @@ var mkdirp = require('mkdirp');
10
10
var indexHtmlTranslator = require ( './indexHtmlTranslator' ) ;
11
11
var regionExtractor = require ( '../doc-shredder/regionExtractor' ) ;
12
12
var COPYRIGHT , COPYRIGHT_JS_CSS , COPYRIGHT_HTML ;
13
+ var README ; // content of plunker.README.md for plunkers
13
14
var SYSTEMJS_CONFIG ; // content of systemjs.config.js for plunkers that use systemjs
14
15
var TSCONFIG ; // content of tsconfig.json for plunkers that use systemjs
15
16
16
-
17
17
module . exports = {
18
18
buildPlunkers : buildPlunkers
19
19
} ;
@@ -30,7 +30,7 @@ function buildCopyrightStrings() {
30
30
}
31
31
32
32
function buildPlunkers ( basePath , destPath , options ) {
33
- getSystemJsConfigPlunker ( basePath ) ;
33
+ getPlunkerFiles ( basePath ) ;
34
34
var errFn = options . errFn || function ( e ) { console . log ( e ) ; } ;
35
35
var plunkerPaths = path . join ( basePath , '**/*plnkr.json' ) ;
36
36
var fileNames = globby . sync ( plunkerPaths , { ignore : "**/node_modules/**" } ) ;
@@ -59,7 +59,7 @@ function buildPlunkerFrom(configFileName, basePath, destPath) {
59
59
try {
60
60
var config = initConfigAndCollectFileNames ( configFileName ) ;
61
61
var postData = createPostData ( config ) ;
62
- addSystemJsConfig ( config , postData ) ;
62
+ addPlunkerFiles ( config , postData ) ;
63
63
var html = createPlunkerHtml ( postData ) ;
64
64
fs . writeFileSync ( outputFileName , html , 'utf-8' ) ;
65
65
if ( altFileName ) {
@@ -81,19 +81,29 @@ function buildPlunkerFrom(configFileName, basePath, destPath) {
81
81
}
82
82
}
83
83
84
- /**
85
- * Add plunker versions of systemjs.config and tsconfig.json
86
- */
87
- function addSystemJsConfig ( config , postData ) {
84
+ function addPlunkerFiles ( config , postData ) {
85
+ addReadme ( config , postData ) ;
88
86
if ( config . basePath . indexOf ( '/ts' ) > - 1 ) {
89
87
// uses systemjs.config.js so add plunker version
90
88
postData [ 'files[systemjs.config.js]' ] = SYSTEMJS_CONFIG ;
91
89
postData [ 'files[tsconfig.json]' ] = TSCONFIG ;
92
90
}
93
91
}
94
92
95
- function getSystemJsConfigPlunker ( basePath ) {
93
+ function addReadme ( config , postData ) {
94
+ var existingFiles = config . fileNames . map ( function ( file ) {
95
+ return file . substr ( file . lastIndexOf ( '/' ) + 1 ) ;
96
+ } ) ;
97
+
98
+ if ( existingFiles . indexOf ( 'README.md' ) === - 1 ) {
99
+ var plunkerReadme = README + config . description ;
100
+ postData [ 'files[README.md]' ] = plunkerReadme ;
101
+ }
102
+ }
103
+
104
+ function getPlunkerFiles ( basePath ) {
96
105
// Assume plunker version is sibling of node_modules version
106
+ README = fs . readFileSync ( basePath + '/plunker.README.md' , 'utf-8' ) ;
97
107
SYSTEMJS_CONFIG = fs . readFileSync ( basePath + '/systemjs.config.plunker.js' , 'utf-8' ) ;
98
108
SYSTEMJS_CONFIG += COPYRIGHT_JS_CSS ;
99
109
TSCONFIG = fs . readFileSync ( basePath + '/tsconfig.json' , 'utf-8' ) ;
0 commit comments