All files gulpfile.ts

44.73% Statements 17/38
100% Branches 0/0
0% Functions 0/1
44.73% Lines 17/38

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 391x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                           1x 1x 1x 1x  
import gulp from 'gulp';
import { spawn } from 'hexo-util';
import { join } from 'upath';
import './clean';
import './gulp.deploy';
import './gulp.feed';
import './gulp.safelink';
import './gulp.seo';
import './post/copy';
import './post/standalone';
import Logger from './utils/logger';
 
// commit current project
export function commitProject(finish: gulp.TaskFunctionCallback) {
  const gitDirs = [join(process.cwd(), 'src-posts'), join(process.cwd(), 'source'), process.cwd()];
  const commit = () => {
    if (!gitDirs.length) return finish();
    const gitDir = gitDirs[0];
    const opt = {
      cwd: gitDir,
      stdio: 'inherit'
    };
    return spawn('git', ['add', '-A'], <any>opt)
      .then(() => spawn('git', ['commit', '-m', 'update ' + new Date()], <any>opt))
      .catch((e) => {
        if (e instanceof Error) Logger.log(e.message, gitDir);
      })
      .finally(() => {
        gitDirs.shift();
        commit();
      });
  };
  return commit();
}
 
gulp.task('project-commit', commitProject);
 
export default gulp;