Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const awsmobileMetaFilePath = pathManager.getCurentBackendCloudAwsmobileMetaFilePath();
const awsmobileMeta = JSON.parse(fs.readFileSync(awsmobileMetaFilePath));
const resourceDir = path.normalize(path.join(
pathManager.getCurrentCloudBackendDirPath(),
category,
resourceName,
));
if (awsmobileMeta[category][resourceName] !== undefined) {
delete awsmobileMeta[category][resourceName];
}
const jsonString = JSON.stringify(awsmobileMeta, null, '\t');
fs.writeFileSync(awsmobileMetaFilePath, jsonString, 'utf8');
filesystem.remove(resourceDir);
}
for (let i = 0; i < resources.length; i += 1) {
const sourceDir = path.normalize(path.join(
pathManager.getBackendDirPath(),
resources[i].category,
resources[i].resourceName,
));
const targetDir = path.normalize(path.join(
pathManager.getCurrentCloudBackendDirPath(),
resources[i].category,
resources[i].resourceName,
));
if (fs.pathExistsSync(targetDir)) {
filesystem.remove(targetDir);
}
fs.ensureDirSync(targetDir);
fs.copySync(sourceDir, targetDir);
}
fs.copySync(amplifyMetaFilePath, amplifyCloudMetaFilePath, { overwrite: true });
fs.copySync(backendConfigFilePath, backendConfigCloudFilePath, { overwrite: true });
}
const amplifyMetaFilePath = pathManager.getCurentAmplifyMetaFilePath();
const amplifyMeta = JSON.parse(fs.readFileSync(amplifyMetaFilePath));
const resourceDir = path.normalize(path.join(
pathManager.getCurrentCloudBackendDirPath(),
category,
resourceName,
));
if (amplifyMeta[category] && amplifyMeta[category][resourceName] !== undefined) {
delete amplifyMeta[category][resourceName];
}
const jsonString = JSON.stringify(amplifyMeta, null, '\t');
fs.writeFileSync(amplifyMetaFilePath, jsonString, 'utf8');
filesystem.remove(resourceDir);
}