Skip to content

Commit

Permalink
fix: updated copy components script (#2483)
Browse files Browse the repository at this point in the history
  • Loading branch information
justyna-13 authored Aug 24, 2022
1 parent ce88f5a commit be0632a
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions packages/vue/scripts/copy-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fse = require("fse");
const path = require("path");
const fs = require("fs");

const srcPath = path.join(__dirname, "../src/");
const srcPath = path.join(__dirname, "../src");
const styleSrcPath = path.join(__dirname, "../../shared");
const targetComponentsPath = path.join(
__dirname,
Expand All @@ -14,36 +14,11 @@ const targetStylesPath = path.join(
__dirname,
"../../../../storefrontUI/styles"
);
const examplesPath = path.join(
__dirname,
"../../../../storefrontUI/components/examples"
);
const componentsPath = path.join(
__dirname,
"../../../../storefrontUI/components"
);

function removeDir(path) {
if (fs.existsSync(path)) {
const files = fs.readdirSync(path);

if (files.length > 0) {
files.forEach((filename) => {
if (fs.statSync(`${path}/${filename}`).isDirectory()) {
removeDir(`${path}/${filename}`);
} else {
fs.unlinkSync(`${path}/${filename}`);
}
});
fs.rmdirSync(path);
} else {
fs.rmdirSync(path);
}
} else {
console.log("Directory path not found.");
}
}

function removeFiles(names, path, flat) {
const removeFilesFlat = () => {
fs.readdirSync(path)
Expand Down Expand Up @@ -135,10 +110,12 @@ function removeFiles(names, path, flat) {

namesToRemove.forEach((filePath) => fs.unlinkSync(filePath));
}
fs.unlinkSync(`${srcPath}/components/templates/internalData.js`, (err) => {
if (err) throw err;
});

fse
.copydir(srcPath, targetComponentsPath)
.then(() => removeDir(examplesPath))
.then(() =>
removeFiles(
["App.vue", "index.js", "main.js", "Playground.vue", "shims-vue.d.ts"],
Expand Down

0 comments on commit be0632a

Please sign in to comment.