Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function processFile(srcPkg, destPkg, prjRelPath) {
const loaders = project.rules.loadersForFile(prjRelPath);
if (loaders.length == 0) {
return Promise.resolve();
}
const fileAbsPath = project.dir.join(prjRelPath).asNative;
const context = {
content: fs.readFileSync(fileAbsPath),
filePath: prjRelPath,
extraArtifacts: {},
log: new PluginLogger(),
};
return runLoaders(loaders, 0, context)
.then(() => writeLoadersResult(srcPkg, destPkg, context))
.then(() => report.rulesRun(prjRelPath, context.log));
}
const {log} = babelIpc.get(state, () => ({
log: new PluginLogger(),
}));
const {log} = babelIpc.get(state, () => ({
log: new PluginLogger(),
}));
const {log} = babelIpc.get(state, () => ({
log: new PluginLogger(),
}));
const {log} = babelIpc.get(state, () => ({
log: new PluginLogger(),
}));
const {log} = babelIpc.get(state, () => ({
log: new PluginLogger(),
}));
.map(filePath => {
filePath = path.resolve(filePath);
const context = {
content: fs.readFileSync(filePath, 'utf-8').toString(),
filePath,
extraArtifacts: {},
log: new PluginLogger(),
};
const loaders = project.rules.loadersForFile(filePath);
if (loaders.length == 0) {
return Promise.resolve();
}
return runLoaders(loaders, 0, context).then(() => {
fs.writeFileSync(filePath, context.content);
Object.entries(context.extraArtifacts).forEach(
([filePath, content]) =>
fs.writeFileSync(filePath, content)
);
return new Promise(resolve => {
const logger = new PluginLogger();
babelIpc.set(project.dir.join(prjRelPath).asNative, {
log: logger,
manifest,
rootPkgJson: clone(project.pkgJson),
globalConfig: clone(project.globalConfig),
});
const fileAbsPath = project.dir.join(prjRelPath).asNative;
const filePkgRelPath = project.dir
.join(destPkg.dir)
.relative(fileAbsPath).asNative;
babel.transformFile(
fileAbsPath,
{
plugins.forEach(plugin => {
const params = {
config: plugin.config,
log: new PluginLogger(),
rootPkgJson: readJsonSync('package.json'),
globalConfig: config.getGlobalConfig(),
pkg: pkg.clone(),
source: {
pkg: srcPkg.clone(),
},
};
plugin.run(params, state);
if (callback) {
callback(plugin, params.log);
}
});