@funnelsgrove/cli 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/localSync.d.ts +1 -0
- package/dist/localSync.js +15 -1
- package/package.json +1 -1
package/dist/localSync.d.ts
CHANGED
package/dist/localSync.js
CHANGED
|
@@ -213,7 +213,8 @@ export async function writeSourceFiles(rootDir, files) {
|
|
|
213
213
|
const relativePath = assertSafeSyncPath(file.path);
|
|
214
214
|
const absolutePath = path.join(rootDir, relativePath);
|
|
215
215
|
await mkdir(path.dirname(absolutePath), { recursive: true });
|
|
216
|
-
|
|
216
|
+
const decodedContent = decodeBinarySourceContent(file);
|
|
217
|
+
await writeFile(absolutePath, decodedContent || file.content, decodedContent ? undefined : 'utf8');
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
async function collectSyncFiles(rootDir, dir) {
|
|
@@ -270,3 +271,16 @@ function decodeDataUrl(content) {
|
|
|
270
271
|
}
|
|
271
272
|
return Buffer.from(match[2].replace(/\s+/g, '').replace(/-/g, '+').replace(/_/g, '/'), 'base64');
|
|
272
273
|
}
|
|
274
|
+
function decodeBase64Content(content) {
|
|
275
|
+
const normalized = content.trim().replace(/\s+/g, '').replace(/-/g, '+').replace(/_/g, '/');
|
|
276
|
+
if (!normalized || !/^[A-Za-z0-9+/=]+$/.test(normalized)) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
return Buffer.from(normalized, 'base64');
|
|
280
|
+
}
|
|
281
|
+
function decodeBinarySourceContent(file) {
|
|
282
|
+
if (file.contentEncoding === 'base64') {
|
|
283
|
+
return decodeBase64Content(file.content);
|
|
284
|
+
}
|
|
285
|
+
return decodeDataUrl(file.content);
|
|
286
|
+
}
|