From cbd2e97fe4328fd8de678c701ce2e32973eff2d6 Mon Sep 17 00:00:00 2001 From: Marcin Polak Date: Sun, 13 Sep 2020 19:59:10 +0200 Subject: [PATCH] cleanups + testing - more done on Linux distros --- lib/osys.js | 5 ++++- nexss-file/lib/fileExtraOptions.js | 27 +++++++++++++++++++----- tests/languages.nexss-test.js | 33 ++++++++++++++++-------------- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/lib/osys.js b/lib/osys.js index c6f7d55..fbb4988 100644 --- a/lib/osys.js +++ b/lib/osys.js @@ -20,7 +20,10 @@ module.exports.version = () => { .execSync("cat /etc/*release | grep -E ^VERSION_ID") .toString() .trim(); - return distName.replace('VERSION_ID="', "").replace('"', ""); + return distName + .replace('VERSION_ID="', "") + .replace('"', "") + .replace("VERSION_ID=", ""); } else { return false; } diff --git a/nexss-file/lib/fileExtraOptions.js b/nexss-file/lib/fileExtraOptions.js index dbb1425..5f2ca06 100644 --- a/nexss-file/lib/fileExtraOptions.js +++ b/nexss-file/lib/fileExtraOptions.js @@ -3,14 +3,14 @@ const { error, success, info, ok } = require("../../lib/log"); const { yellow, red, bold } = require("../../lib/color"); const { which } = require("../../lib/terminal"); const fs = require("fs"); -module.exports.extraFunctions = templatePath => { +module.exports.extraFunctions = (templatePath) => { // Extra operation for the template like installations, files copy, info if (fs.existsSync(`${templatePath}.js`)) { console.log("Additional files and commands for this file. Please wait.."); const extraOptions = require(`${templatePath}.js`); const files = extraOptions.files || []; const path = require("path"); - files.forEach(element => { + files.forEach((element) => { const elementPath = path.join(path.dirname(templatePath), element); const destinationPath = NEXSS_PROJECT_SRC_PATH ? path.join(NEXSS_PROJECT_SRC_PATH, path.dirname(element)) @@ -40,14 +40,31 @@ ${ let commands = extraOptions.commands; if (commands && commands.forEach) { + const { + replaceCommandByDist, + dist, + } = require(`${process.env.NEXSS_SRC_PATH}/lib/osys`); + + // const distName = dist(); + + // TODO: Later to cleanup this config file !! + // switch (distName) { + // default: + // languageConfig.compilers.ruby.install = replaceCommandByDist( + // languageConfig.compilers.ruby.install + // ); + // break; + // } + // FIXME: to check this part!! - commands.forEach(cmd => { + commands.forEach((cmd2) => { // TODO: better error handling // console.log(cmd); + cmd = replaceCommandByDist(cmd2); if (cmd) { try { require("child_process").execSync(`${cmd}`, { - stdio: "inherit" + stdio: "inherit", }); } catch (err) { error("=========================================================="); @@ -82,7 +99,7 @@ ${ const descriptions = extraOptions.descriptions || []; if (descriptions.length > 0) { // warn("Some information about installed packages."); - descriptions.forEach(desc => { + descriptions.forEach((desc) => { info(bold("Info from additional third party libraries package:")); info(desc); }); diff --git a/tests/languages.nexss-test.js b/tests/languages.nexss-test.js index 9ac4cbb..a744726 100644 --- a/tests/languages.nexss-test.js +++ b/tests/languages.nexss-test.js @@ -10,6 +10,13 @@ let values = Object.keys(languages); //values = []; // values = values.slice(1, 30); +const { + replaceCommandByDist, + dist, +} = require(`${process.env.NEXSS_SRC_PATH}/lib/osys`); + +const distName = dist(); + module.exports = { values, testsSelect: [1, 2], @@ -22,7 +29,6 @@ module.exports = { ".swift", // is not implemented on windows yet // OTHER ISSUES // ".html", - ".tcl", // Wrong unicode characters ".pd", // To check ".ps1", // ".d", // dome compiler proble, default.d not found @@ -49,32 +55,21 @@ module.exports = { : [ ".cpp", // Oracle Linux 8 does dont have rapid json in the main repo ".cc", + ".groovy", // sdk PATH is not reloaded (the same as rust) - How to reload / from child_process of nodejs ".html", // is used only for templates + ".swift", // NOT AVAILABLE ON LINUX/MAC - ".ahk", - ".au3", - ".vbs", - ".wsf", - ".pd", - ".bat", + // Other issues ".jl", // issues with the permissions etc. look later - ".ps1", //Shows Error on nexss my.ps1 --nocache --nxsTest --x=123 ### ERROR on linux. ".cs", //Sometimes shows dotnet-script not found - ".ex", // Better install - ".exs", - ".erl", // TO implement ".hs", // TO implement - ".hx", // TO implement ".java", // TO implement, ".kts", // TO IMPLEMENT default, helloWorld ".kt", // TO IMPLEMENT default, helloWorld - ".rb", // TO implement ".scala", // TO implement - ".nim", // TO implement ".hy", // TO implement ".coco", // TO IMPLEMENT default, helloWorld - ".coco", // TO IMPLEMENT default, helloWorld ".f90", // TO IMPLEMENT default, helloWorld ".d", // ACtivate function / make it automatic ".v", // TO implement @@ -83,6 +78,14 @@ module.exports = { ".m", // TO implement ".raku", // finish installer ".adb", // Ada: TO IMPLEMENT default, helloWorld (filename must be default not Default!) + // ======================================================================================= + // ONLY WINDOWS BELOW - SO NOT IMPLEMENTED + ".ahk", + ".au3", + ".vbs", + ".wsf", + ".pd", + ".bat", ], tests: [ {