@chevtek/cli
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -68,3 +68,3 @@ "use strict"; | ||
var npxCmd = /^win/.test(process.platform) ? "npx.cmd" : "npx"; | ||
exports.default = (function (dir) { return __awaiter(void 0, void 0, void 0, function () { | ||
exports.default = (function (dir, force) { return __awaiter(void 0, void 0, void 0, function () { | ||
var dirExists, files; | ||
@@ -82,4 +82,4 @@ return __generator(this, function (_a) { | ||
files = _a.sent(); | ||
if (files.length > 0) { | ||
throw new Error("Target directory is not empty."); | ||
if (!force && (files.length > 1 || path_1.default.basename(files[0]) !== ".git")) { | ||
throw new Error("Target directory is not empty. Supply --force to generate anyway."); | ||
} | ||
@@ -86,0 +86,0 @@ return [3 /*break*/, 5]; |
@@ -57,2 +57,8 @@ #!/usr/bin/env node | ||
}); | ||
yargs.option("force", { | ||
type: "boolean", | ||
default: false, | ||
alias: "f", | ||
description: chalk_1.default.redBright("Force template generation even if directory is not empty.") | ||
}); | ||
yargs.positional("path", { | ||
@@ -59,0 +65,0 @@ type: "string", |
@@ -28,3 +28,3 @@ import fs from "fs"; | ||
export default async (dir: string) => { | ||
export default async (dir: string, force: boolean) => { | ||
console.log(chalk.greenBright("Generating full-stack scaffold...")); | ||
@@ -34,4 +34,4 @@ const dirExists = await checkDirectoryExists(dir); | ||
const files = await readdir(dir); | ||
if (files.length > 0) { | ||
throw new Error("Target directory is not empty."); | ||
if (!force && (files.length > 1 || path.basename(files[0]) !== ".git")) { | ||
throw new Error("Target directory is not empty. Supply --force to generate anyway."); | ||
} | ||
@@ -38,0 +38,0 @@ } else { |
@@ -20,2 +20,8 @@ #!/usr/bin/env node | ||
}); | ||
yargs.option("force", { | ||
type: "boolean", | ||
default: false, | ||
alias: "f", | ||
description: chalk.redBright("Force template generation even if directory is not empty.") | ||
}); | ||
yargs.positional("path", { | ||
@@ -22,0 +28,0 @@ type: "string", |
{ | ||
"name": "@chevtek/cli", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36299
729