1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2025-01-25 01:32:58 +02:00

38 lines
924 B
JavaScript
Raw Normal View History

2024-03-25 01:38:18 +08:00
#!/usr/bin/env node
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';
import {getDirnameFromImportMeta} from '../../sdk.mjs';
2024-03-19 13:35:59 +01:00
const __dirname = getDirnameFromImportMeta(import.meta.url);
const rootDirectory = path.resolve(__dirname, '..', '..');
const files = ['index.js', 'index.mjs', 'index.d.ts', 'sdk.js'];
const fileExists = (fpath) =>
2024-03-25 01:38:18 +08:00
fs
.access(fpath, fs.constants.F_OK)
.then(() => true)
.catch(() => false);
2024-03-19 13:35:59 +01:00
2024-03-25 01:38:18 +08:00
try {
Promise.all(
files.map(async (file) => {
const filepath = path.join(rootDirectory, file);
if (!(await fileExists(filepath))) {
console.error(`File ${file} does not exist, skipping...`);
return;
}
return fs.unlink(filepath);
}),
);
} catch (error) {
console.error('Error cleaning files:', error);
2024-03-19 13:35:59 +01:00
process.exit(1);
2024-03-25 01:38:18 +08:00
}