Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ yarn
skip
npm
travis
yarn-skip
yarn-skip
force
forcef
force-f
747 changes: 380 additions & 367 deletions build-index.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions index-tests/force.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { executeBashFunction, cli } from "./utils.js";

test("When force exists, it should reject", async () => {
try {
const folder = "force";
await executeBashFunction(`mkdir ${folder}`);
process.argv.push(folder);
await cli();
} catch (e) {
expect(e.message.indexOf("file already exists")).toBeGreaterThan(-1);
}
});
11 changes: 11 additions & 0 deletions index-tests/forcef.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { executeBashFunction, cli, doesFileExist } from "./utils.js";

test("When forcef exists and you pass -f, it should delete it and work!", async () => {
const folder = "forcef";
await executeBashFunction(`mkdir ${folder}`);
process.argv.push(folder);
process.argv.push("-f");
process.argv.push("-s");
await cli();
expect(await doesFileExist(folder)).toBeTruthy();
});
7 changes: 5 additions & 2 deletions index-tests/git.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { executeBashFunction, doesFileExist } from "./utils";
import { cli, doesFileExist } from "./utils";

test("When passing -g, .gitignore should be created", async () => {
const folder = "git";
await executeBashFunction(`node index.js ${folder} -s -g`);
process.argv.push(folder);
process.argv.push("-s");
process.argv.push("-g");
await cli();
const result = await doesFileExist(`${folder}/.gitignore`);
expect(result).toBeTruthy();
});
7 changes: 3 additions & 4 deletions index-tests/npm.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { executeBashFunction, executeBuild, doesFileExist } from "./utils";
import { cli, executeBuild, doesFileExist } from "./utils";

test("using npm", async () => {
const folder = "npm";
await executeBashFunction(`node index.js ${folder}`);
process.argv.push(folder);
await cli();
await executeBuild(folder);
const doesPackageLockExist = await doesFileExist(`${folder}/package-lock.json`);
expect(doesPackageLockExist).toBeTruthy();
});


7 changes: 5 additions & 2 deletions index-tests/skip.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { executeBashFunction, doesFileExist } from "./utils";
import { doesFileExist, cli } from "./utils";

test("When passing -s, node_modules shouldn't be installed", async () => {
const folder = "skip";
await executeBashFunction(`node index.js ${folder} -s`);
process.argv.push(folder);
process.argv.push("-s");
await cli();
expect(await doesFileExist(folder)).toBeTruthy();
const result = await doesFileExist(`${folder}/node_modules`);
expect(result).not.toBeTruthy();
});
7 changes: 5 additions & 2 deletions index-tests/travis.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { executeBashFunction, doesFileExist } from "./utils";
import { cli, doesFileExist } from "./utils";

test("When passing -t, .travis.yml should be created", async () => {
const folder = "travis";
await executeBashFunction(`node index.js ${folder} -s -t`);
process.argv.push(folder);
process.argv.push("-s");
process.argv.push("-t");
await cli();
const result = await doesFileExist(`${folder}/.travis.yml`);
expect(result).toBeTruthy();
});
11 changes: 8 additions & 3 deletions index-tests/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const { exec } = require("child_process");
const fs = require("fs-extra");

import { exec } from "child_process";
import fs from "fs-extra";

import reactCli from "../index";


const executeFunction = func => {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -29,5 +33,6 @@ export const doesFileExist = async path => {
} catch (error) {
return false;
}
};

};
export const cli = () => reactCli();
4 changes: 2 additions & 2 deletions index-tests/yarn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { executeBashFunction, executeBuild, doesFileExist } from "./utils";

test.skip("when passing -y, yarn should be used.", async () => {
const folder = "yarn";
await executeBashFunction(`node index.js ${folder} -y`);
await executeBashFunction(`node main.js ${folder} -y`);
await executeBuild(folder);
const doesYarnLockExist = await doesFileExist(`${folder}/yarn.lock`);
expect(doesYarnLockExist).toBeTruthy();
});

test.skip("When skipping installation, node_modules should not be there", async () => {
const folder = "yarn-skip";
await executeBashFunction(`node index.js ${folder} -y -s`);
await executeBashFunction(`node main.js ${folder} -y -s`);
const doesNodeModulesExist = await doesFileExist(`${folder}/node_modules`);
expect(doesNodeModulesExist).toBeTruthy();
});
Expand Down
Loading