Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return through2.obj(function (file, enc, cb) {
if (file.isNull()) {
this.push(file);
return cb();
}
if (file.isStream()) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME,
'Streaming not supported'));
return cb();
}
var options = opts || {};
var contents = file.contents.toString();
var applause = Applause.create(options);
var result = applause.replace(contents);
if (result !== false) {
file.contents = new Buffer(result);
} else {
// preserve original file
}
this.push(file);
cb();
});
sections[section] = contents;
}
// write readme
var Applause = require('applause');
var options = {
patterns: [{
match: 'options',
replacement: function() {
var name = 'Applause Options';
return sections[name] || '_(Coming soon)_'; // empty
}
}]
};
var applause = Applause.create(options);
var result = applause.replace(fs.readFileSync('docs/README.md', 'utf8'));
fs.writeFileSync('README.md', result.content, 'utf8');
}, {
match: '__TARGET_PATH__',
replacement: function(match, offset, string, source, target) {
return path.dirname(target);
},
builtin: true
}, {
match: '__TARGET_FILENAME__',
replacement: function(match, offset, string, source, target) {
return path.basename(target);
},
builtin: true
});
}
// create applause instance
var applause = Applause.create(_.extend({}, options, {
// pass
}));
// took code from copy task
var isExpandedPair;
var dirs = {};
var tally = {
dirs: 0,
files: 0,
replacements: 0,
details: []
};
this.files.forEach(function(filePair) {
isExpandedPair = filePair.orig.expand || false;
filePair.src.forEach(function(src) {
src = unixifyPath(src);
var dest = unixifyPath(filePair.dest);
},
{
match: /(<|<\/)block.*>/g,
replacement: ''
},
{
match: /!\[(.*)\]\((.*)\)/g,
replacement: function () {
let description = arguments[1];
let file = arguments[2];
return `![${description}](./versions/${version}/${file})`;
}
}
]
};
var applause = Applause.create(options);
let tocMarkdown = [];
function replaceOptions(data) {
let result = applause.replace(data);
if (result.content) {
return result.content;
}
return data;
}
function writeMdString(item, callback) {
const filename = `.tmp/${item.file}.md`;
let data = `# ${item.title}\n\n`;
data += fs.readFileSync(`versions/${version}/docs/${item.file}.md`);
data = replaceOptions(data);
fs.appendFile(filename, data, function(err) {