Skip to content

Commit

Permalink
Remove unused files when project generated is not serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeriochaves committed Nov 7, 2018
1 parent b727016 commit 9aee1d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/createApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ module.exports = async (name, cmd) => {
path.join(name, ".gitignore")
);

if (cmd.serverless) serverlessPackage(name);
if (cmd.serverless) {
serverlessPackage(name);
} else {
removeServerlessFiles(name);
}

await replaceProjectname(name);
await initializeGit(name);
Expand Down Expand Up @@ -59,6 +63,12 @@ function serverlessPackage(name) {
);
}

function removeServerlessFiles(name) {
fs.unlinkSync(path.join(name, "src", "index.static.ejs"));
fs.unlinkSync(path.join(name, "package.static.json"));
fs.unlinkSync(path.join(name, "webpack.config.static.js"));
}

async function replaceProjectname(name) {
try {
await replaceInFiles({ files: name, from: "projectname", to: name });
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/createApp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ test(
.split("\n");
ignoredFiles.push(".gitignore.template");
ignoredFiles.push(".DS_Store");
ignoredFiles.push("package.static.json");
ignoredFiles.push("webpack.config.static.js");

let boilerplateFiles = fs
.readdirSync("boilerplate")
Expand Down

0 comments on commit 9aee1d2

Please sign in to comment.