All files / packages/design-tokens/scripts clean.ts

0% Statements 0/13
0% Branches 0/4
100% Functions 0/0
0% Lines 0/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                   
import fs from 'node:fs/promises';
import path from 'node:path';
import { existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
 
// Setup directory
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const root = path.resolve(__dirname, '../');
const distPath = path.resolve(root, 'dist');
 
try {
  const exists = existsSync(distPath);
 
  if (exists) {
    await fs.rm(distPath, { recursive: true, force: true });
    await fs.mkdir(distPath, { recursive: true });
    console.log('clean dist/: cleaned');
  } else {
    console.log('clean dist/: skipped, not found (will be created on build)');
  }
} catch (err) {
  console.error('clean dist/: error -', err instanceof Error ? err.message : err);
  process.exit(1);
}