Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiankaegy committed Sep 24, 2024
1 parent ee914c0 commit 95aeb0f
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions packages/toolkit/utils/blocks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path');
const { getFileContentHash } = require('./file');

const JS_ASSET_KEYS = ['script', 'editorScript', 'viewScript', 'viewScriptModule', 'scriptModule'];

/**
* Transform the asset path from `.ts or .tsx` to `.js`
*
Expand Down Expand Up @@ -62,25 +64,11 @@ const transformBlockJson = (content, absoluteFilename) => {
newMetadata.version = styleFileContentHash;
}

if (metadata.script) {
newMetadata.script = transformTSAsset(metadata.script);
}

if (metadata.editorScript) {
newMetadata.editorScript = transformTSAsset(metadata.editorScript);
}

if (metadata.viewScript) {
newMetadata.viewScript = transformTSAsset(metadata.viewScript);
}

if (metadata.viewScriptModule) {
newMetadata.viewScriptModule = transformTSAsset(metadata.viewScriptModule);
}

if (metadata.scriptModule) {
newMetadata.scriptModule = transformTSAsset(metadata.scriptModule);
}
JS_ASSET_KEYS.forEach((key) => {
if (metadata[key]) {
newMetadata[key] = transformTSAsset(metadata[key]);
}
});

return JSON.stringify(newMetadata, null, 2);
};
Expand Down

0 comments on commit 95aeb0f

Please sign in to comment.