@@ -10,10 +10,10 @@ var mkdirp = require('mkdirp');
1010var indexHtmlTranslator = require ( './indexHtmlTranslator' ) ;
1111var regionExtractor = require ( '../doc-shredder/regionExtractor' ) ;
1212var COPYRIGHT , COPYRIGHT_JS_CSS , COPYRIGHT_HTML ;
13+ var README ; // content of plunker.README.md for plunkers
1314var SYSTEMJS_CONFIG ; // content of systemjs.config.js for plunkers that use systemjs
1415var TSCONFIG ; // content of tsconfig.json for plunkers that use systemjs
1516
16-
1717module . exports = {
1818 buildPlunkers : buildPlunkers
1919} ;
@@ -30,7 +30,7 @@ function buildCopyrightStrings() {
3030}
3131
3232function buildPlunkers ( basePath , destPath , options ) {
33- getSystemJsConfigPlunker ( basePath ) ;
33+ getPlunkerFiles ( basePath ) ;
3434 var errFn = options . errFn || function ( e ) { console . log ( e ) ; } ;
3535 var plunkerPaths = path . join ( basePath , '**/*plnkr.json' ) ;
3636 var fileNames = globby . sync ( plunkerPaths , { ignore : "**/node_modules/**" } ) ;
@@ -59,7 +59,7 @@ function buildPlunkerFrom(configFileName, basePath, destPath) {
5959 try {
6060 var config = initConfigAndCollectFileNames ( configFileName ) ;
6161 var postData = createPostData ( config ) ;
62- addSystemJsConfig ( config , postData ) ;
62+ addPlunkerFiles ( config , postData ) ;
6363 var html = createPlunkerHtml ( postData ) ;
6464 fs . writeFileSync ( outputFileName , html , 'utf-8' ) ;
6565 if ( altFileName ) {
@@ -81,19 +81,29 @@ function buildPlunkerFrom(configFileName, basePath, destPath) {
8181 }
8282}
8383
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 ) ;
8886 if ( config . basePath . indexOf ( '/ts' ) > - 1 ) {
8987 // uses systemjs.config.js so add plunker version
9088 postData [ 'files[systemjs.config.js]' ] = SYSTEMJS_CONFIG ;
9189 postData [ 'files[tsconfig.json]' ] = TSCONFIG ;
9290 }
9391}
9492
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 ) {
96105 // Assume plunker version is sibling of node_modules version
106+ README = fs . readFileSync ( basePath + '/plunker.README.md' , 'utf-8' ) ;
97107 SYSTEMJS_CONFIG = fs . readFileSync ( basePath + '/systemjs.config.plunker.js' , 'utf-8' ) ;
98108 SYSTEMJS_CONFIG += COPYRIGHT_JS_CSS ;
99109 TSCONFIG = fs . readFileSync ( basePath + '/tsconfig.json' , 'utf-8' ) ;
0 commit comments