Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
feat(init): add entries to .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
rudxde committed Mar 2, 2022
1 parent b3cc3bf commit 47bc39f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/init/src/main.ts
Expand Up @@ -9,13 +9,14 @@ export async function main(args: IInitArgs): Promise<void> {
// issue: https://github.com/microsoft/TypeScript/issues/43329
const ora = await (eval('import("ora")') as Promise<typeof import('ora')>);
const chalk = (await (eval('import("chalk")') as Promise<typeof import('chalk')>)).default;

const spinner = ora.default('Installing lerna-dockerize').start();
try {
await installLernaDockerize(args);
await addTemplates(args);
await addConfig(args);
await addScripts(args);
await addToGitIgnore(args);
spinner.succeed('lerna-dockerize was successfully installed!');
console.log(`\nnow try to run:`);
console.log(`\t${chalk.yellow('>')} ${chalk.underline.blue(`npm run lerna-dockerize`)}`);
Expand Down Expand Up @@ -100,3 +101,18 @@ async function addScripts(args: IInitArgs): Promise<void> {
const indentation = detectIdent(packageJson);
await fsPromises.writeFile(packageJsonPath, JSON.stringify(packageJsonObject, undefined, indentation));
}

async function addToGitIgnore(args: IInitArgs): Promise<void> {
const gitIgnorePath = joinPath(args.workingDirectory ?? process.cwd(), '.gitignore');
let gitignore = '';
if (existsSync(gitIgnorePath)) {
gitignore = await fsPromises.readFile(gitIgnorePath, 'utf8');
}
gitignore += '\n\n';
gitignore += [
'# lerna-dockerize',
'# generated by lerna-dockerize',
'package-slim.json',
'Dockerfile',
].join('\n');
}

0 comments on commit 47bc39f

Please sign in to comment.