Updates
This commit is contained in:
+6
-4
@@ -3,6 +3,7 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
import grabDbNames from "../package-shared/utils/grab-db-names";
|
||||
|
||||
require("dotenv").config({
|
||||
path: path.resolve(process.cwd(), ".env"),
|
||||
@@ -17,9 +18,10 @@ const mysqlDumpPath = process.platform?.match(/win/i)
|
||||
"'"
|
||||
: "mysqldump";
|
||||
|
||||
const { DSQL_USER, DSQL_PASS, DSQL_DB_NAME } = process.env;
|
||||
const { DSQL_USER, DSQL_PASS } = process.env;
|
||||
|
||||
const { dbFullName } = grabDbNames();
|
||||
|
||||
const dbName = DSQL_DB_NAME || "";
|
||||
const dumpFilePathArg = process.argv.indexOf("--file");
|
||||
|
||||
if (dumpFilePathArg < 0) {
|
||||
@@ -29,7 +31,7 @@ if (dumpFilePathArg < 0) {
|
||||
|
||||
const dumpFilePath = process.argv[dumpFilePathArg + 1];
|
||||
|
||||
if (!dbName?.match(/./)) {
|
||||
if (!dbFullName?.match(/./)) {
|
||||
console.log("DSQL_DB_NAME is required in your `.env` file");
|
||||
process.exit();
|
||||
}
|
||||
@@ -47,7 +49,7 @@ try {
|
||||
// if (process.platform.match(/win/i)) execSyncOptions.shell = "bash.exe";
|
||||
|
||||
const dump = execSync(
|
||||
`${mysqlPath} -u ${DSQL_USER} -p${DSQL_PASS} ${dbName} < ${dumpFilePath}`,
|
||||
`${mysqlPath} -u ${DSQL_USER} -p${DSQL_PASS} ${dbFullName} < ${dumpFilePath}`,
|
||||
execSyncOptions
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user