@gdjiami/cli
Version:
CLI for build front end project.
35 lines (34 loc) • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var path_1 = tslib_1.__importDefault(require("path"));
var fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
var utils_1 = require("../../utils");
function createGitIgnore(appPath, ownPath) {
var dotIgnorePath = path_1.default.join(appPath, '.gitignore');
var ignorePath = path_1.default.join(appPath, 'gitignore');
if (fs_extra_1.default.existsSync(dotIgnorePath)) {
return;
}
if (fs_extra_1.default.existsSync(ignorePath)) {
fs_extra_1.default.moveSync(ignorePath, dotIgnorePath);
return;
}
var defaultIgnorePath = path_1.default.join(ownPath, 'lib/gitignore');
fs_extra_1.default.copySync(defaultIgnorePath, dotIgnorePath);
utils_1.message.info('created .gitignore');
}
function createGitAttribute(appPath, ownPath) {
var dotGitAttributesPath = path_1.default.join(appPath, '.gitattributes');
if (fs_extra_1.default.existsSync(dotGitAttributesPath)) {
return;
}
var defaultGitAttributesPath = path_1.default.join(ownPath, 'lib/gitattributes');
fs_extra_1.default.copySync(defaultGitAttributesPath, dotGitAttributesPath);
utils_1.message.info('create .gitattributes');
}
var genGitignore = function (appPath, ownPath) {
createGitIgnore(appPath, ownPath);
createGitAttribute(appPath, ownPath);
};
exports.default = genGitignore;