Skip to content

Commit

Permalink
refactor: imporve useage
Browse files Browse the repository at this point in the history
Co-authored-by: uncenter <[email protected]>
  • Loading branch information
isabelroses and uncenter committed Dec 13, 2023
1 parent f3cd5b5 commit 9400414
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions scripts/import-styles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,20 @@ const stylesheets = walk(join(REPO_ROOT, "styles", subDir), {
});

// Recommended settings.
const settings = JSON.stringify({
settings: {
updateInterval: 24,
updateOnlyEnabled: true,
patchCsp: true
}
})

var data = '[' + settings + ',';
const settings = {
settings: {
updateInterval: 24,
updateOnlyEnabled: true,
patchCsp: true
}
};

const entries = [];
const data = [settings];
for await (const entry of stylesheets) {
entries.push(entry);
}

for (let i = 0; i < entries.length; i++) {
const content = await Deno.readTextFile(entries[i].path);

const content = await Deno.readTextFile(entry.path);
const {metadata} = usercssMeta.parse(content);

const final = JSON.stringify({
data.push({
enabled: true,
name: metadata.name,
description: metadata.description,
Expand All @@ -47,16 +40,9 @@ for (let i = 0; i < entries.length; i++) {
usercssData: metadata,
sourceCode: content
});

let closingTag = ',';
if (i === entries.length - 1) {
closingTag = ']';
}

data += final + closingTag;
}

Deno.writeTextFile("compiled.json", data)
Deno.writeTextFile("compiled.json", JSON.stringify(data))

// if any files are missing, cause the workflow to fail
if (await checkForMissingFiles() === false) {
Expand Down

0 comments on commit 9400414

Please sign in to comment.