-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
executable file
·43 lines (38 loc) · 1.18 KB
/
index.ts
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
import { exec } from 'child_process'
import { writeFile } from 'fs'
import { fileContent } from './files/fileContent'
// Define the npm commands you want to run
const npmCommands = [
'npm install tailwindcss postcss autoprefixer postcss-cli',
'npx tailwindcss init',
]
// Function to run npm commands
const runNpmCommands = () => {
npmCommands.forEach((command, index) => {
// Execute each command
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Error executing command: ${command}`)
console.error(stderr)
} else {
console.log(`Command executed successfully: ${command}`)
console.log(stdout)
// After the last command has finished, write the files
if (index === npmCommands.length - 1) {
fileContent.forEach((file) =>
writeFile(file.path, file.content, (err) => {
if (err) {
console.error(`Error writing to ${file.path}: ${err}`)
} else {
console.log(`Successfully wrote to ${file.path}`)
}
})
)
}
}
})
})
}
// Run the npm commands
runNpmCommands()