UNPKG

@arc-fusion/cli

Version:

CLI for running Arc Fusion on your local machine

30 lines (22 loc) 1.12 kB
'use strict' const fs = require('node:fs/promises') const path = require('node:path') const { PROJECT_ROOT } = require('../environment') async function types () { const typesDir = path.join(PROJECT_ROOT, 'types') await fs.mkdir(typesDir, { recursive: true }) // Create the index file if it doesn't exist const indexPath = path.join(typesDir, 'index.d.ts') if (!(await fs.stat(indexPath).catch(() => false))) { await fs.writeFile(indexPath, '// Your project-specific type definitions go here\n') process.stdout.write(`Type definitions directory created at ${indexPath}\n`) } // Patch the index file to include the `.d.ts` file from myself const indexFileContent = await fs.readFile(indexPath, 'utf8') if (!/^\s*import\s+(?:.*\s+from\s+)["']@arc-fusion\/cli["'];?\s*$/.test(indexFileContent)) { const importStatement = '// Import helper types from Fusion CLI\nimport "@arc-fusion/cli";\n\n' await fs.writeFile(indexPath, `${importStatement}${indexFileContent}`) process.stdout.write(`Patched ${indexPath} to include types from @arc-fusion/cli\n`) } } module.exports = types