* fix: app-store-cli windows support issue #10324 * fix: app-store-cli windows support issue #10324 - remove yarn.lock * fix: app-store-cli windows support issue #10324 * refactor: instead of repeating code, use constant to know if it is windows platform
This commit is contained in:
1 parent
4e1e586541
commit
0f0b55488f
2 files changed
+7
-5
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
|
||||
export const APP_STORE_PATH = path.join(__dirname, "..", "..", "app-store");
|
||||
export const TEMPLATES_PATH = path.join(APP_STORE_PATH, "templates");
|
||||
export const IS_WINDOWS_PLATFORM = os.platform() === "win32";
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
import { APP_STORE_PATH, TEMPLATES_PATH } from "./constants";
|
||||
import { APP_STORE_PATH, TEMPLATES_PATH, IS_WINDOWS_PLATFORM} from "./constants";
|
||||
import execSync from "./utils/execSync";
|
||||
|
||||
const slugify = (str: string) => {
|
||||
@@ -69,8 +69,8 @@ export const BaseAppFork = {
|
||||
}) {
|
||||
const appDirPath = getAppDirPath(slug, isTemplate);
|
||||
if (!editMode) {
|
||||
await execSync(`mkdir -p ${appDirPath}`);
|
||||
await execSync(`cp -r ${TEMPLATES_PATH}/${template}/* ${appDirPath}`);
|
||||
await execSync(IS_WINDOWS_PLATFORM ? `mkdir ${appDirPath}` : `mkdir -p ${appDirPath}`);
|
||||
await execSync(IS_WINDOWS_PLATFORM ? `xcopy "${TEMPLATES_PATH}\\${template}\\*" "${appDirPath}" /e /i` : `cp -r ${TEMPLATES_PATH}/${template}/* ${appDirPath}`);
|
||||
} else {
|
||||
if (!oldSlug) {
|
||||
throw new Error("oldSlug is required when editMode is true");
|
||||
@@ -79,7 +79,7 @@ export const BaseAppFork = {
|
||||
// We need to rename only if they are different
|
||||
const oldAppDirPath = getAppDirPath(oldSlug, isTemplate);
|
||||
|
||||
await execSync(`mv ${oldAppDirPath} ${appDirPath}`);
|
||||
await execSync(IS_WINDOWS_PLATFORM ? `move ${oldAppDirPath} ${appDirPath}` : `mv ${oldAppDirPath} ${appDirPath}`);
|
||||
}
|
||||
}
|
||||
updatePackageJson({ slug, appDirPath, appDescription: description });
|
||||
@@ -126,7 +126,7 @@ export const BaseAppFork = {
|
||||
|
||||
delete: async function ({ slug, isTemplate }: { slug: string; isTemplate: boolean }) {
|
||||
const appDirPath = getAppDirPath(slug, isTemplate);
|
||||
await execSync(`rm -rf ${appDirPath}`);
|
||||
await execSync(IS_WINDOWS_PLATFORM ? `rd /s /q ${appDirPath}` : `rm -rf ${appDirPath}`);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user