Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert chalk 5 because of ESM #75

Closed
wants to merge 7 commits into from
Closed
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
8 changes: 2 additions & 6 deletions Commands/gitInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ const gitInitCommand = {
try {
chalk.Message("Checking whether git is initialised");
process.chdir(folderPath);
if (
execSync("git status", { stdio: [] })
.toString()
.startsWith("On branch")
) {
if (execSync("git status").toString().startsWith("On branch")) {
chalk.Warning("git already initialised");
}
} catch (error) {
try {
chalk.Message("git initialisation started");
execSync("git init -b main", { stdio: [] });
execSync("git init -b main");
chalk.Success("git initialisation completed");
} catch (error) {
chalk.Error("git was not initialised");
Expand Down
10 changes: 5 additions & 5 deletions Commands/gitInit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test("gitInit: git already initialised", () => {
expect(command).toHaveBeenCalled();
expect(execSync).toHaveBeenCalledTimes(2);
// execSync("git --version")
// execSync("git status", { stdio: [] })
// execSync("git status")
expect(chdir).toHaveBeenCalled();
expect(exit).not.toHaveBeenCalled();

Expand Down Expand Up @@ -69,8 +69,8 @@ test("gitInit: git needs initialisation & succeeds", () => {
expect(command).toHaveBeenCalled();
expect(execSync).toHaveBeenCalledTimes(3);
// execSync("git --version")
// execSync("git status", { stdio: [] })
// execSync("git init -b main", { stdio: [] });
// execSync("git status")
// execSync("git init -b main");
expect(chdir).toHaveBeenCalled();
expect(exit).not.toHaveBeenCalled();

Expand Down Expand Up @@ -104,8 +104,8 @@ test("gitInit: git needs initialisation & fails", () => {
expect(command).toHaveBeenCalled();
expect(execSync).toHaveBeenCalledTimes(3);
// execSync("git --version")
// execSync("git status", { stdio: [] })
// execSync("git init -b main", { stdio: [] });
// execSync("git status")
// execSync("git init -b main");
expect(chdir).toHaveBeenCalled();
expect(writeFileSync).toHaveBeenCalledWith(
"err.log",
Expand Down
10 changes: 7 additions & 3 deletions Jest/globalSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ const wpFolderPath = require("../Utils/folderPaths").wpFolderPath();

module.exports = function () {
// save current working dir in to revert to it in teardown

process.env.initialPath = process.cwd();
execSync("npm link", {
stdio: [],
});
runningInGitHub = process.env.GITHUB_JOB === undefined ? false : true;

runningInGitHub && execSync("npm cache clean --force");
runningInGitHub && execSync("npm link");

fs.mkdirSync(parentFolderPath, { recursive: true });

Expand All @@ -19,6 +21,8 @@ module.exports = function () {
"yo",
];

runningInGitHub && packagesToInstallGlobally.push("spfx-fast-serve");

console.log();
console.log(process.version);
if (process.version.startsWith("v16")) {
Expand Down
2 changes: 1 addition & 1 deletion Jest/globalTeardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const parentFolderPath = require("../Utils/folderPaths").parentFolderPath();
module.exports = function () {
process.chdir(os.homedir());

execSync("npm uninstall prettier sort-package-json --global", { stdio: [] });
execSync("npm uninstall prettier sort-package-json --global");

fs.rmSync(parentFolderPath, {
recursive: true,
Expand Down
18 changes: 15 additions & 3 deletions Tests/e2e/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,25 @@ beforeEach(() => {
process.chdir(parentFolderPath_IndexTest);
execSync(
`yo @microsoft/sharepoint --solution-name "VanillaSolution" --framework "react"` +
` --component-type "webpart" --component-name "WebPart1" --skip-install --environment "spo" `,
{ stdio: [] }
` --component-type "webpart" --component-name "WebPart1" --skip-install --environment "spo" `
);

process.chdir(wpFolderPath_IndexTest);

execSync(`spfx-jack -v -f -g -s -p`);
console.log("process.env.initialPath");
console.log();

console.log("executing spfx-jack commands: gitInit");
const indexPath = join(process.env.initialPath, "index.js");
execSync(`node ${indexPath} -g`);
console.log("executing spfx-jack commands: npmVersion");
execSync(`spfx-jack -v`);
console.log("executing spfx-jack commands: fastServe");
execSync(`spfx-jack -f`);
console.log("executing spfx-jack commands: sortPackage");
execSync(`spfx-jack -s`);
console.log("executing spfx-jack commands: prettier");
execSync(`spfx-jack -p`);
});

test("indexTest: fast-serve folder created", () => {
Expand Down
4 changes: 2 additions & 2 deletions Utils/gitCommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const chalk = require("./chalk");

module.exports = function (commitMessage) {
try {
execSync("git add .", { stdio: [] });
execSync(`git commit -m "` + commitMessage + `"`, { stdio: [] });
execSync("git add .");
execSync(`git commit -m "` + commitMessage + `"`);
chalk.Success("git commit: " + commitMessage);
} catch (error) {
try {
Expand Down
Loading
Loading