2024-03-25 01:38:18 +08:00
|
|
|
#!/usr/bin/env node
|
2025-03-04 03:12:53 +01:00
|
|
|
// @ts-check
|
2024-03-19 13:35:59 +01:00
|
|
|
/**
|
2024-06-06 14:40:35 +02:00
|
|
|
* @file
|
2024-03-19 13:35:59 +01:00
|
|
|
* Clean files built by the build process.
|
|
|
|
*/
|
|
|
|
|
2024-03-25 01:38:18 +08:00
|
|
|
import fs from 'node:fs/promises';
|
2024-03-19 13:35:59 +01:00
|
|
|
import path from 'node:path';
|
2024-03-25 01:38:18 +08:00
|
|
|
import process from 'node:process';
|
2025-06-25 16:55:30 +02:00
|
|
|
import {fileExists} from '../utils.js';
|
2024-03-19 13:35:59 +01:00
|
|
|
|
2025-06-24 22:27:40 +02:00
|
|
|
const files = [
|
|
|
|
'index.js',
|
|
|
|
'index-icons.js',
|
|
|
|
'index.mjs',
|
|
|
|
'index-icons.mjs',
|
|
|
|
'index.d.ts',
|
|
|
|
'sdk.js',
|
|
|
|
];
|
2024-03-19 13:35:59 +01:00
|
|
|
|
2024-03-25 01:38:18 +08:00
|
|
|
try {
|
2024-12-21 22:49:25 +08:00
|
|
|
Promise.all(
|
|
|
|
files.map(async (file) => {
|
2025-05-27 19:22:37 +08:00
|
|
|
const filepath = path.resolve(import.meta.dirname, '..', '..', file);
|
2024-12-21 22:49:25 +08:00
|
|
|
if (!(await fileExists(filepath))) {
|
|
|
|
console.error(`File ${file} does not exist, skipping...`);
|
|
|
|
return;
|
|
|
|
}
|
2024-03-25 01:38:18 +08:00
|
|
|
|
2024-12-21 22:49:25 +08:00
|
|
|
return fs.unlink(filepath);
|
|
|
|
}),
|
|
|
|
);
|
2024-03-25 01:38:18 +08:00
|
|
|
} catch (error) {
|
2024-12-21 22:49:25 +08:00
|
|
|
console.error('Error cleaning files:', error);
|
|
|
|
process.exit(1);
|
2024-03-25 01:38:18 +08:00
|
|
|
}
|