Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let findFileWithExtname = (extname: string) => {
let filePath = replaceExt(this.resourcePath, `.${extname}`)
// @ts-ignore
return fs.exists(filePath).then(isExist => ({ isExist, filePath }))
}
return pAny(extnames.map(findFileWithExtname), {
new Error(
'The api `translations` of mina-loader is deprecated. Please use `transform` instead.'
)
)
}
const originalRequest = loaderUtils.getRemainingRequest(this)
const filePath = this.resourcePath
let relativePath = path.relative(this.rootContext, filePath)
// move some files into subpackages
// .js files are moved in entry plugin but .json/.wxss/.wxml should be handled here
// @ts-ignore
const subpackageMapping: Record = this.subpackageMapping || {}
const entryName = replaceExt(helpers.toSafeOutputPath(relativePath), '')
if (subpackageMapping[entryName]) {
relativePath = subpackageMapping[entryName] + '.mina'
}
const dirname = compose(
ensurePosix,
helpers.toSafeOutputPath,
path.dirname
)(relativePath)
getBlocks(this, originalRequest)
.then(blocks =>
Promise.all(
[...TAGS_FOR_FILE_LOADER, ...TAGS_FOR_OUTPUT].map(async (tag: Tag) => {
let result: BlockResult = {
tag,
log(`Rendering file: ${filename} ${relativeFilename}`);
// Translate the YML specs to JSON
const inputYML = await fs.readFile(filename, 'utf8');
const inputJSON = yaml.load(inputYML);
inputJSON.ymlFileName = `/${path.relative(rootFolder, filename)}`;
const validationErrors = validate(inputJSON, validator);
if (validationErrors) {
throw new Error(`Data validation error for ${filename}: ${JSON.stringify(validationErrors)}`);
}
// Pass the inputJS into our Handlebars template
const markdown = template(inputJSON);
// Write the markdown to its right place
const markdownPath = replaceExt(relativeFilename, '.md');
const outfile = path.resolve(rootFolder, 'docs', 'en', markdownPath);
log(` Writing to: ${outfile}`);
await mkdirp(path.dirname(outfile));
await fs.writeFile(outfile, markdown, 'utf8');
fileCount++;
}
log(`Done writing ${fileCount} command documents`);
}
function stripExt(path: string): string {
return replaceExt(path, '')
}
changeExtension(path, newExtension) {
return replaceExt(path, newExtension);
}
path => replaceExt(path, '.js'),
urlToRequest,
return global.__wxConfig.tabBar.list.map(({ pagePath }) => {
return extname(pagePath, '')
})
}