Skip to content

Commit c924c00

Browse files
committed
feat: update gitignore on configure
1 parent e5011c6 commit c924c00

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

configure.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,35 @@
1414

1515
import ConfigureCommand from '@adonisjs/core/commands/configure'
1616
import { stubsRoot } from './stubs/main.js'
17+
import { FileSystem } from './src/filesystem.js'
1718

1819
export async function configure(command: ConfigureCommand) {
20+
const filesystem = new FileSystem()
1921
const codemods = await command.createCodemods()
2022

2123
await codemods.updateRcFile((rcFile) => {
2224
rcFile.addCommand('@bitkidd/adonisjs-credentials/commands')
2325
})
2426

2527
await codemods.makeUsingStub(stubsRoot, 'start.stub', {})
28+
29+
try {
30+
const oldGitIgnoreFile = await filesystem.read({ path: `${command.app.makePath()}/.gitignore` })
31+
const keyRuleExists = oldGitIgnoreFile.includes('*.key')
32+
33+
if (keyRuleExists) {
34+
command.logger.action('update .gitignore file').skipped()
35+
} else {
36+
const newGitIgnoreFile = `${oldGitIgnoreFile}\n*.key\n`
37+
38+
await filesystem.write({
39+
path: `${command.app.makePath()}/.gitignore`,
40+
data: newGitIgnoreFile,
41+
})
42+
43+
command.logger.action('update .gitignore file').succeeded()
44+
}
45+
} catch (error) {
46+
command.logger.action('update .gitignore file').failed(error)
47+
}
2648
}

0 commit comments

Comments
 (0)