diff --git a/website/src/repl/create_strudel_json.mjs b/website/src/repl/create_strudel_json.mjs index d07c67928..4eedd458d 100644 --- a/website/src/repl/create_strudel_json.mjs +++ b/website/src/repl/create_strudel_json.mjs @@ -1,27 +1,28 @@ - import { createInterface } from 'node:readline'; -import * as fs from 'node:fs' +import * as fs from 'node:fs'; -const validFileTypes = new Set(['.wav', '.mp3', '.aac', '.m4a']) +const validFileTypes = new Set(['.wav', '.mp3', '.aac', '.m4a']); /** For automatically creating the strudel JSON that for samples hosted in a remote repo */ async function writeStrudelJson(subpath, hosturl) { const children = await fs.promises.readdir(subpath, { recursive: true }); const name = subpath.split('/').slice(-1)[0]; const tree = { name, children }; let samples = { - _base: hosturl + _base: hosturl, }; - const files = tree.children.filter((path) => { - const extension = path.match(/\.[0-9a-z]+$/i)?.[0] - return validFileTypes.has(extension) - }).sort((a, b) => a.localeCompare(b)) + const files = tree.children + .filter((path) => { + const extension = path.match(/\.[0-9a-z]+$/i)?.[0]; + return validFileTypes.has(extension); + }) + .sort((a, b) => a.localeCompare(b)); - files.forEach(path => { - const groupName = path.match(/([^/]+)\/[^/]+$/)[1] - samples[groupName] = samples[groupName] ?? [] - samples[groupName].push(path) - }) + files.forEach((path) => { + const groupName = path.match(/([^/]+)\/[^/]+$/)[1]; + samples[groupName] = samples[groupName] ?? []; + samples[groupName].push(path); + }); const json = JSON.stringify(samples, null, 2); const filepath = subpath + '/strudel.json'; await fs.promises.writeFile(filepath, json); @@ -33,20 +34,19 @@ const rl = createInterface({ output: process.stdout, }); -rl.question(`enter sample folder path: `, async path => { - rl.question(`enter hosted URL: `, async hosturl => { +rl.question(`enter sample folder path: `, async (path) => { + rl.question(`enter hosted URL: `, async (hosturl) => { const githubregex = /github\.com\/([^/]+)\/([^/]+)/; const githubparams = hosturl.match(githubregex); if (githubparams) { const username = githubparams[1]; const repo = githubparams[2]; - hosturl = `https://raw.githubusercontent.com/${username}/${repo}/main/` - console.log('reformatting github URL to: ', hosturl) + hosturl = `https://raw.githubusercontent.com/${username}/${repo}/main/`; + console.log('reformatting github URL to: ', hosturl); } - await writeStrudelJson(path, hosturl) + await writeStrudelJson(path, hosturl); rl.close(); - }) - -}); \ No newline at end of file + }); +});