Skip to content

Commit

Permalink
feat: .ignore文件的检查和创建
Browse files Browse the repository at this point in the history
  • Loading branch information
AKclown committed May 30, 2022
1 parent 1dd3f98 commit 2cd1ee3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions models/git/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const GIT_TOKEN_FILE = '.git_token';
const GIT_OWN_FILE = '.git_own';
// 缓存登录名称 (个人名称/组织名称)
const GIT_LOGIN_FILE = '.git_login';
// .ignore文件
const GIT_IGNORE_FILE = '.gitignore';

// Git托管平台
const GITHUB = 'github';
Expand Down Expand Up @@ -96,6 +98,8 @@ class Git {
await this.checkGitOwner();
// $ 检查并创建远程仓库
await this.checkRepo();
// $ 检查并创建.gitignore文件
this.checkGitIgnore();
}

// 检查缓存主目录
Expand Down Expand Up @@ -278,6 +282,28 @@ class Git {
this.repo = repo;
}

// 检查并创建.gitignore文件
checkGitIgnore() {
const gitIgnorePath = path.resolve(this.dir, GIT_IGNORE_FILE);
if (!fs.existsSync(gitIgnorePath)) {
writeFile(
gitIgnorePath,
`.idea/
.DS_Store
node_modules/
package-lock.json
yarn.lock
.vscode/
.history/
logs/
target/
pid`
);

log.success(`自动写入${GIT_IGNORE_FILE}文件成功`);
}
}

// 获取git server 的文件路径
createPath(file) {
const rootDir = path.resolve(this.homePath, GIT_ROOT_DIR);
Expand Down

0 comments on commit 2cd1ee3

Please sign in to comment.