|
1 | 1 | #!/usr/bin/env node |
2 | | - |
3 | | -import childProcess from 'node:child_process' |
4 | 2 | import fs from 'node:fs' |
5 | 3 | import path from 'node:path' |
6 | | -import { exit } from 'node:process' |
7 | | -import { fileURLToPath } from 'node:url' |
| 4 | +import process from 'node:process' |
8 | 5 |
|
9 | 6 | import pkg from './package.json' with { type: 'json' } |
10 | 7 | import { saveFile } from './save-file.mjs' |
11 | 8 |
|
12 | | -const __dirname = path.dirname(fileURLToPath(import.meta.url)) |
| 9 | +const __dirname = path.dirname(new URL(import.meta.url).pathname) |
| 10 | +const currentPath = process.cwd() |
13 | 11 | let isUsingConventionalCommits = false |
14 | | -let gitRoot |
15 | 12 |
|
16 | 13 | console.info(`[${pkg.name}] Running...`) |
17 | 14 |
|
18 | | -try { |
19 | | - gitRoot = childProcess |
20 | | - .execSync('git rev-parse --show-toplevel') |
21 | | - .toString() |
22 | | - .trim() |
23 | | -} catch { |
24 | | - console.error(`\u001B[0;31m[${pkg.name}] Could not get root path\u001B[0m`) |
25 | | - exit() |
26 | | -} |
27 | | - |
28 | 15 | // check if uses conventional commits |
29 | 16 | const installedPackages = JSON.parse( |
30 | | - fs.readFileSync(path.join(gitRoot, 'package.json'), 'utf8'), |
| 17 | + fs.readFileSync(path.join(currentPath, 'package.json'), 'utf8'), |
31 | 18 | ) |
32 | 19 |
|
33 | 20 | if ( |
|
37 | 24 | isUsingConventionalCommits = true |
38 | 25 | } |
39 | 26 |
|
40 | | -const githubDestinationFolder = path.join(gitRoot, '.github') |
| 27 | +const githubDestinationFolder = path.join(currentPath, '.github') |
41 | 28 |
|
42 | 29 | const codeOwnersFileName = 'CODEOWNERS' |
43 | 30 | const codeOwnersSource = path.join(__dirname, 'assets', codeOwnersFileName) |
|
0 commit comments