forked from sveltejs/kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.js
executable file
·27 lines (24 loc) · 817 Bytes
/
bin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node
import fs from 'node:fs';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import colors from 'kleur';
const migration = process.argv[2];
const dir = fileURLToPath(new URL('.', import.meta.url));
const migrations = fs
.readdirSync(`${dir}/migrations`)
.filter((migration) => fs.existsSync(`${dir}/migrations/${migration}/index.js`));
if (migrations.includes(migration)) {
const { migrate } = await import(`./migrations/${migration}/index.js`);
migrate();
} else {
console.error(
colors
.bold()
.red(
`You must specify one of the following migrations: ${migrations.join(', ')}\n` +
'If you expected this to work, try re-running the command with the latest svelte-migrate version:\n' +
` npx svelte-migrate@latest ${migration}`
)
);
}