devkit-js
Version:
Devkit CLI is a Command Line tool for superfast scaffolding of any simple Vanilla JavaScript App
29 lines (24 loc) • 741 B
JavaScript
const fs = require('fs');
const git = require('simple-git')();
const util = require('util');
const path = require('path');
const writeFile = util.promisify(fs.writeFile);
class Git {
static gitignore = async () => {
const gitignoreContent = 'node_modules\ndist\npublic\ndevelopment\n.cache';
try {
await writeFile('.gitignore', gitignoreContent);
} catch (error) {
throw new Error('Error.Git: unable to create .gitignore file');
}
};
static init = async () => {
git.cwd(path.resolve(`${process.cwd()}`));
try {
await git.init();
} catch (error) {
throw new Error('Error.Git: unable to initalize a git repository!');
}
};
}
module.exports = Git;