Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stream.use(({ files }) => {
let fileList = Object.keys(stream.files)
// Exclude binary path
fileList = fileList.filter(fp => !isBinaryPath(fp))
if (action.transformInclude) {
fileList = matcher(fileList, action.transformInclude)
}
if (action.transformExclude) {
fileList = matcher.not(fileList, action.transformExclude)
}
fileList.forEach(relativePath => {
const contents = files[relativePath].contents.toString()
const transformer = require('jstransformer')(
require(`jstransformer-${config.transformer || 'ejs'}`)
)
const templateData = action.templateData || config.templateData
stream.writeContents(
relativePath,
transformer.render(
contents,
config.transformerOptions,
Object.assign(
{},
context.answers,
filter: (dir: string, files: string[]) => {
// NOTE: ignore 为空数组时会忽略全部文件
if (!ignore || !ignore.length) return files
return micromatch.not(files, ignore)
}
})
return new Promise((resolve, reject) => {
let matches;
if (!Array.isArray(ignoreGlobs) || !ignoreGlobs.length) {
resolve(uris);
}
try {
// Get uris not matching from micromatch
matches = micromatch.not(
Array.from(uris, uri => uri.fsPath), ignoreGlobs
);
// Convert back to Uris and resolve
resolve({
uris: Array.from(matches, match => vscode.Uri.file(match)),
ignored: (uris.length - matches.length)
});
} catch(e) {
reject(e);
}
});
}
function removeDirectories(files) {
const match = micromatch.not(files, [
'**/testing/**',
'**/demo/**',
]);
return match.join(' ');
}
'*.md': files =>
micromatch
.not(files, '*CHANGELOG.md')
.map(file => `markdownlint ${file}; prettier --write ${file}; git add ${file};`),
'**/package.json': ['prettier-package-json --write', 'git add']
'*.{md,js,jsx}': files => {
const match = micromatch.not(files, [
'**/__tests__/**/expected/**/*.js',
'**/tests/fixtures/**/output.js',
]);
return match.length > 1
? [`prettier ${match.join(' ')} --write`, `git add ${match.join(' ')}`]
: [];
},
};
stream.use(({ files }) => {
let fileList = Object.keys(stream.files)
if (action.transformInclude) {
fileList = matcher(fileList, action.transformInclude)
}
if (action.transformExclude) {
fileList = matcher.not(fileList, action.transformExclude)
}
fileList.forEach(relativePath => {
const contents = files[relativePath].contents.toString()
const transformer = require('jstransformer')(
require(`jstransformer-${action.transformer ||
config.transformer ||
'ejs'}`)
)
stream.writeContents(
relativePath,
transformer.render(
contents,
action.transformerOptions,
Object.assign({}, context.answers, {
sao: context