Skip to content

Commit 926d67d

Browse files
authored
Merge pull request #308 from IBM/autocvt
Turn on _BPXK_AUTOCVT for npm
2 parents 9330b4b + 04f474f commit 926d67d

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

__tests__/api/BundlePush/BundlePusher.test.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -935,9 +935,9 @@ describe("BundlePusher01", () => {
935935
});
936936

937937
await runPushTestWithError("__tests__/__resources__/ExampleBundle01", false,
938-
"A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/v8r0/IBM/node-latest-os390-s390x/bin\" " +
939-
"&& npm install' in remote directory '/u/ThisDoesNotExist/12345678'. " +
940-
"Problem is: The output from the remote command implied that an error occurred, return code 1.");
938+
"A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/v8r0/IBM/node-latest-os390-s390x/bin\"" +
939+
" && export _BPXK_AUTOCVT=ON && npm install' in remote directory '/u/ThisDoesNotExist/12345678'." +
940+
" Problem is: The output from the remote command implied that an error occurred, return code 1.");
941941

942942
expect(consoleText).toContain("Injected stdout error message");
943943
expect(zosMFSpy).toHaveBeenCalledTimes(1);
@@ -968,9 +968,9 @@ describe("BundlePusher01", () => {
968968
});
969969

970970
await runPushTestWithError("__tests__/__resources__/ExampleBundle01", false,
971-
"A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/v8r0/IBM/node-latest-os390-s390x/bin\" " +
972-
"&& npm install' in remote directory '/u/ThisDoesNotExist/12345678'. " +
973-
"Problem is: The output from the remote command implied that an error occurred, return code 1.");
971+
"A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/v8r0/IBM/node-latest-os390-s390x/bin\"" +
972+
" && export _BPXK_AUTOCVT=ON && npm install' in remote directory '/u/ThisDoesNotExist/12345678'." +
973+
" Problem is: The output from the remote command implied that an error occurred, return code 1.");
974974

975975
expect(consoleText).toContain("Injected FSUM7351 not found message");
976976
expect(zosMFSpy).toHaveBeenCalledTimes(1);
@@ -1001,9 +1001,9 @@ describe("BundlePusher01", () => {
10011001
});
10021002

10031003
await runPushTestWithError("__tests__/__resources__/ExampleBundle01", false,
1004-
"A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/v8r0/IBM/node-latest-os390-s390x/bin\" " +
1005-
"&& npm install' in remote directory '/u/ThisDoesNotExist/12345678'. " +
1006-
"Problem is: The output from the remote command implied that an error occurred, return code 1.");
1004+
"A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/v8r0/IBM/node-latest-os390-s390x/bin\"" +
1005+
" && export _BPXK_AUTOCVT=ON && npm install' in remote directory '/u/ThisDoesNotExist/12345678'." +
1006+
" Problem is: The output from the remote command implied that an error occurred, return code 1.");
10071007

10081008
expect(consoleText).toContain("Injected npm ERR! Exit status 1 message");
10091009
expect(zosMFSpy).toHaveBeenCalledTimes(1);
@@ -1080,6 +1080,16 @@ describe("BundlePusher01", () => {
10801080
expect(readdirSpy).toHaveBeenCalledTimes(1);
10811081
expect(lstatSpy).toHaveBeenCalledTimes(1);
10821082
});
1083+
it("should set up auto conversion before running npm install", async () => {
1084+
readdirSpy.mockImplementation((data: string) => {
1085+
return [ "package.json" ];
1086+
});
1087+
await runPushTest("__tests__/__resources__/ExampleBundle01", false, "PUSH operation completed");
1088+
expect(shellSpy).toBeCalledWith(expect.anything(),
1089+
expect.stringContaining("_BPXK_AUTOCVT=ON"),
1090+
expect.anything(),
1091+
expect.anything());
1092+
});
10831093
it("should run npm install for each package.json", async () => {
10841094
const parms = getCommonParmsForPushTests();
10851095
parms.arguments.verbose = true;

src/api/BundlePush/BundlePusher.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class BundlePusher {
3737
private fs = require("fs");
3838
private progressBar: ITaskWithStatus;
3939
private defaultRemoteNodehomeCmd = "export PATH=\"$PATH:/usr/lpp/IBM/cnj/v8r0/IBM/node-latest-os390-s390x/bin\"";
40+
private envSetupCommand = "export _BPXK_AUTOCVT=ON";
4041

4142
/**
4243
* Constructor for a BundlePusher.
@@ -517,7 +518,9 @@ export class BundlePusher {
517518
this.updateStatus("Running 'npm install' in remote directory");
518519
}
519520

520-
await this.runSshCommandInRemoteDirectory(sshSession, remoteDirectory, this.defaultRemoteNodehomeCmd + " && npm install");
521+
await this.runSshCommandInRemoteDirectory(sshSession,
522+
remoteDirectory,
523+
this.defaultRemoteNodehomeCmd + " && " + this.envSetupCommand + " && npm install");
521524
}
522525

523526
private async runSingleNpmUninstall(sshSession: SshSession, remoteDirectory: string) {
@@ -530,7 +533,8 @@ export class BundlePusher {
530533

531534
// uninstall each module individually
532535
await this.runSshCommandInRemoteDirectory(sshSession, remoteDirectory, this.defaultRemoteNodehomeCmd + " && " +
533-
"if [ -d \"node_modules\" ] && [ \"$(ls node_modules)\" ]; then npm uninstall `ls -1 node_modules | tr '/\n' ' '`; fi");
536+
this.envSetupCommand + " && " +
537+
"if [ -d \"node_modules\" ] && [ \"$(ls node_modules)\" ]; then npm uninstall `ls -1 node_modules | tr '/\n' ' '`; fi");
534538
}
535539

536540
private async runSshCommandInRemoteDirectory(sshSession: SshSession, directory: string, sshCommand: string) {

0 commit comments

Comments
 (0)