refactor: some changes to plunkerBuilder

closes #1885
This commit is contained in:
Jesús Rodríguez 2016-07-14 16:10:23 +02:00 committed by Ward Bell
parent abe9dbe092
commit 4ff714c99f
1 changed files with 5 additions and 9 deletions

View File

@ -9,7 +9,7 @@ var mkdirp = require('mkdirp');
var indexHtmlTranslator = require('./indexHtmlTranslator'); var indexHtmlTranslator = require('./indexHtmlTranslator');
var regionExtractor = require('../doc-shredder/regionExtractor'); var regionExtractor = require('../doc-shredder/regionExtractor');
var COPYRIGHT, COPYRIGHT_JS, COPYRIGHT_HTML; var COPYRIGHT, COPYRIGHT_JS_CSS, COPYRIGHT_HTML;
var SYSTEMJS_CONFIG; // content of systemjs.config.js for plunkers that use systemjs var SYSTEMJS_CONFIG; // content of systemjs.config.js for plunkers that use systemjs
var TSCONFIG; // content of tsconfig.json for plunkers that use systemjs var TSCONFIG; // content of tsconfig.json for plunkers that use systemjs
@ -32,11 +32,8 @@ function buildCopyrightStrings() {
function buildPlunkers(basePath, destPath, options) { function buildPlunkers(basePath, destPath, options) {
getSystemJsConfigPlunker(basePath); getSystemJsConfigPlunker(basePath);
var errFn = options.errFn || function(e) { console.log(e); }; var errFn = options.errFn || function(e) { console.log(e); };
var configExtns = ['plnkr.json', '*plnkr.json']; var plunkerPaths = path.join(basePath, '**/*plnkr.json');
var gpaths = configExtns.map(function(extn) { var fileNames = globby.sync(plunkerPaths, { ignore: "**/node_modules/**"});
return path.join(basePath, '**/' + extn);
});
var fileNames = globby.sync(gpaths, { ignore: "**/node_modules/**"});
fileNames.forEach(function(configFileName) { fileNames.forEach(function(configFileName) {
try { try {
buildPlunkerFrom(configFileName, basePath, destPath); buildPlunkerFrom(configFileName, basePath, destPath);
@ -51,7 +48,7 @@ function buildPlunkers(basePath, destPath, options) {
// description: optional string - description of this plunker - defaults to the title in the index.html page. // description: optional string - description of this plunker - defaults to the title in the index.html page.
// tags: [] - optional array of strings // tags: [] - optional array of strings
// main: string - filename of what will become index.html in the plunker - defaults to index.html // main: string - filename of what will become index.html in the plunker - defaults to index.html
function buildPlunkerFrom(configFileName, basePath, destPath ) { function buildPlunkerFrom(configFileName, basePath, destPath) {
// replace ending 'plnkr.json' with 'plnkr.no-link.html' to create output file name; // replace ending 'plnkr.json' with 'plnkr.no-link.html' to create output file name;
var outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.json'.length) + 'plnkr.no-link.html'; var outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.json'.length) + 'plnkr.no-link.html';
var altFileName; var altFileName;
@ -90,8 +87,7 @@ function buildPlunkerFrom(configFileName, basePath, destPath ) {
function addSystemJsConfig(config, postData){ function addSystemJsConfig(config, postData){
if (config.basePath.indexOf('/ts') > -1) { if (config.basePath.indexOf('/ts') > -1) {
// uses systemjs.config.js so add plunker version // uses systemjs.config.js so add plunker version
var relativeFileName = 'systemjs.config.js'; postData['files[systemjs.config.js]'] = SYSTEMJS_CONFIG;
postData['files[' + relativeFileName + ']'] = SYSTEMJS_CONFIG;
postData['files[tsconfig.json]'] = TSCONFIG; postData['files[tsconfig.json]'] = TSCONFIG;
} }
} }