Skip to content

Commit 0364a8d

Browse files
authored
remove shelljs (#89)
* remove shelljs * oops
1 parent 526fcdc commit 0364a8d

File tree

4 files changed

+24
-92
lines changed

4 files changed

+24
-92
lines changed

apps/svelte.dev/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"prettier-plugin-svelte": "^3.2.4",
8181
"satori": "^0.10.13",
8282
"satori-html": "^0.3.2",
83-
"shelljs": "^0.8.5",
8483
"shiki": "^1.6.4",
8584
"shiki-twoslash": "^3.1.2",
8685
"svelte": "5.0.0-next.243",

apps/svelte.dev/scripts/update.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import sh from 'shelljs';
1+
import { fork } from 'node:child_process';
2+
import { fileURLToPath } from 'url';
23

3-
sh.env['FORCE_UPDATE'] = process.argv.includes('--force=true');
4+
const dir = fileURLToPath(new URL('.', import.meta.url));
45

5-
Promise.all([
6-
sh.exec('node ./scripts/get_contributors.js'),
7-
sh.exec('node ./scripts/get_donors.js'),
8-
sh.exec('node ./scripts/update_template.js')
9-
]);
6+
const env = {
7+
FORCE_UPDATE: process.argv.includes('--force=true') || ''
8+
};
9+
10+
fork(`${dir}/get_contributors.js`, { env });
11+
fork(`${dir}/get_donors.js`, { env });
12+
fork(`${dir}/update_template.js`);
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
// @ts-check
2-
import { lstat, readFile, stat, writeFile } from 'node:fs/promises';
3-
import path, { dirname } from 'node:path';
2+
import fs from 'node:fs';
43
import { fileURLToPath } from 'node:url';
5-
import sh from 'shelljs';
4+
import { execSync } from 'node:child_process';
5+
import glob from 'tiny-glob/sync.js';
66

77
const force = process.env.FORCE_UPDATE === 'true';
88

9-
const __dirname = dirname(fileURLToPath(import.meta.url));
10-
sh.cd(path.join(__dirname, '..'));
9+
const dir = fileURLToPath(new URL('./svelte-app', import.meta.url));
1110

1211
const outputFile = 'static/svelte-app.json';
1312

1413
try {
15-
if (!force && (await stat(outputFile))) {
14+
if (!force && fs.existsSync(outputFile)) {
1615
console.info(`[update/template] ${outputFile} exists. Skipping`);
1716
process.exit(0);
1817
}
1918
} catch {
2019
// fetch svelte app
21-
sh.rm('-rf', 'scripts/svelte-app');
22-
sh.exec('npx degit sveltejs/template scripts/svelte-app');
20+
fs.rmdirSync(dir);
21+
execSync(`npx degit sveltejs/template ${dir}`);
2322

2423
// remove src (will be recreated client-side) and node_modules
25-
sh.rm('-rf', 'scripts/svelte-app/src');
26-
sh.rm('-rf', 'scripts/svelte-app/node_modules');
24+
fs.rmdirSync(`${dir}/src`);
25+
fs.rmdirSync(`${dir}/node_modules`);
2726

2827
// build svelte-app.json
29-
const appPath = 'scripts/svelte-app';
28+
const appPath = dir;
3029
const files = [];
3130

32-
for (const path of sh.find(appPath)) {
31+
for (const path of glob(`${dir}/**`)) {
3332
// Skip directories
34-
if (!(await lstat(path)).isFile()) continue;
33+
if (!fs.lstatSync(path).isFile()) continue;
3534

36-
const bytes = await readFile(path);
35+
const bytes = fs.readFileSync(path);
3736
const string = bytes.toString();
3837
const data = bytes.compare(Buffer.from(string)) === 0 ? string : [...bytes];
3938
files.push({ path: path.slice(appPath.length + 1), data });
4039
}
4140

42-
writeFile(outputFile, JSON.stringify(files));
41+
fs.writeFileSync(outputFile, JSON.stringify(files));
4342
}

pnpm-lock.yaml

Lines changed: 0 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)