close #36
This commit is contained in:
@@ -134,7 +134,35 @@ class CompilerTools {
|
|||||||
case JavaScript:
|
case JavaScript:
|
||||||
command = "node";
|
command = "node";
|
||||||
scriptExt = "js";
|
scriptExt = "js";
|
||||||
// npm install outputfolder
|
// npm install outputfolder
|
||||||
|
if (args.langProjectFile != null) {
|
||||||
|
// This can only be done in the current working directory, so the project file needs to be moved here
|
||||||
|
// Move existing package.json, package-lock.json, node_modules out of the way:
|
||||||
|
function move(file, newName) {
|
||||||
|
if (FileSystem.exists(file)) {
|
||||||
|
FileSystem.rename(file, newName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
move("package.json", "package.json.temp");
|
||||||
|
move("package-lock.json", "package-lock.json.temp");
|
||||||
|
move("node_modules", "node_modules.temp");
|
||||||
|
|
||||||
|
File.copy(args.langProjectFile, "package.json");
|
||||||
|
|
||||||
|
if (Sys.systemName() == "Windows") {
|
||||||
|
Prelude.assertProcess("cmd.exe", ["/c", 'npm', 'install']);
|
||||||
|
} else {
|
||||||
|
Prelude.assertProcess("npm", ['install']);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSystem.deleteFile("package.json");
|
||||||
|
move("node_modules", Prelude.joinPath(args.outputFolder, "node_modules"));
|
||||||
|
move("package-lock.json", Prelude.joinPath(args.outputFolder, "package-lock.json"));
|
||||||
|
|
||||||
|
move("package.json.temp", "package.json");
|
||||||
|
move("package-lock.json.temp", "package-lock.json");
|
||||||
|
move("node_modules.temp", "node_modules");
|
||||||
|
}
|
||||||
case Python:
|
case Python:
|
||||||
command = "python";
|
command = "python";
|
||||||
scriptExt = "py";
|
scriptExt = "py";
|
||||||
|
@@ -29,7 +29,7 @@ class CompilerToolsTestCase extends Test {
|
|||||||
return CompilerTools.compileFileToScript(
|
return CompilerTools.compileFileToScript(
|
||||||
"kiss/template/src/template/Main.kiss", JavaScript, {
|
"kiss/template/src/template/Main.kiss", JavaScript, {
|
||||||
outputFolder: "bin/helloWorldJsTestWithPackageJson",
|
outputFolder: "bin/helloWorldJsTestWithPackageJson",
|
||||||
// langProjectFile: "kiss/src/test/files/package.json"
|
langProjectFile: "kiss/src/test/files/package.json"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user