@eljs/create
Version:
Create a project from a remote template.
61 lines (59 loc) • 1.85 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/internal/plugins/git-init.ts
var git_init_exports = {};
__export(git_init_exports, {
default: () => git_init_default
});
module.exports = __toCommonJS(git_init_exports);
var import_utils = require("@eljs/utils");
var git_init_default = async (api) => {
api.describe({
enable() {
return Boolean(api.config.gitInit);
}
});
async function shouldInitGit() {
if (!await (0, import_utils.hasGit)()) {
return false;
}
if (await (0, import_utils.hasProjectGit)(api.paths.target)) {
return false;
}
if (api.prompts.git === false || api.prompts.git === "false") {
return false;
}
return true;
}
api.onGenerateDone(
async () => {
const initGit = await shouldInitGit();
if (initGit) {
console.log();
import_utils.logger.info(`🗃 Initializing git repository ...`);
await (0, import_utils.run)("git", ["init"], {
cwd: api.paths.target,
verbose: false
});
}
},
{
stage: Number.NEGATIVE_INFINITY
}
);
};