Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 818c82c

Browse files
Foxandxsswardbell
authored andcommitted
chore: add README.md to each plunker
closes #1974
1 parent 04d5337 commit 818c82c

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Angular 2 Documentation Example
2+

tools/plunker-builder/plunkerBuilder.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ var mkdirp = require('mkdirp');
1010
var indexHtmlTranslator = require('./indexHtmlTranslator');
1111
var regionExtractor = require('../doc-shredder/regionExtractor');
1212
var COPYRIGHT, COPYRIGHT_JS_CSS, COPYRIGHT_HTML;
13+
var README; // content of plunker.README.md for plunkers
1314
var SYSTEMJS_CONFIG; // content of systemjs.config.js for plunkers that use systemjs
1415
var TSCONFIG; // content of tsconfig.json for plunkers that use systemjs
1516

16-
1717
module.exports = {
1818
buildPlunkers: buildPlunkers
1919
};
@@ -30,7 +30,7 @@ function buildCopyrightStrings() {
3030
}
3131

3232
function 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

Comments
 (0)