in tools/plunker-builder/builder.js [66:100]
_buildPlunkerFrom(configFileName) {
// replace ending 'plnkr.json' with 'plnkr.no-link.html' to create output file name;
var outputFileName = `${this.options.plunkerFileName}.no-link.html`;
outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.json'.length) + outputFileName;
var altFileName;
if (this.destPath && this.destPath.length > 0) {
var partPath = path.dirname(path.relative(this.basePath, outputFileName));
var altFileName = path.join(this.destPath, partPath, path.basename(outputFileName)).replace('.no-link.', '.');
}
try {
var config = this._initConfigAndCollectFileNames(configFileName);
var postData = this._createPostData(config);
this._addPlunkerFiles(config, postData);
var html = this._createPlunkerHtml(config, postData);
if (this.options.writeNoLink) {
fs.writeFileSync(outputFileName, html, 'utf-8');
}
if (altFileName) {
var altDirName = path.dirname(altFileName);
if (!fs.existsSync(altDirName)) {
mkdirp.sync(altDirName);
}
fs.writeFileSync(altFileName, html, 'utf-8');
}
} catch (e) {
// if we fail delete the outputFile if it exists because it is an old one.
if (this._existsSync(outputFileName)) {
fs.unlinkSync(outputFileName);
}
if (altFileName && this._existsSync(altFileName)) {
fs.unlinkSync(altFileName);
}
throw e;
}
}