@modern-js/codesmith-api-json
Version:
codesmith json api
15 lines (14 loc) • 420 B
JavaScript
async function editJson(generatorCore, resource, getNewJsonValue) {
const originJsonValue = await resource.value();
const newJsonString = await getNewJsonValue(originJsonValue.content);
if (!newJsonString) {
throw new Error("get new json string is undefined");
}
await generatorCore.output.fs(resource.filePath, newJsonString, {
encoding: "utf-8"
});
return newJsonString;
}
export {
editJson
};