diff --git a/source/main.ts b/source/main.ts index 809e921..850ef04 100644 --- a/source/main.ts +++ b/source/main.ts @@ -27,8 +27,10 @@ namespace _munin command : string, { "log_only": log_only = false, + "working_directory": working_directory = null, } : { log_only ?: boolean; + working_directory ?: (null | string); } = { } ) : Promise< @@ -64,6 +66,7 @@ namespace _munin nm_child_process.exec( command, { + "cwd": ((working_directory === null) ? undefined : working_directory), }, (error, stdout, stderr) => { if (error) { @@ -218,35 +221,34 @@ namespace _munin for (const lib of data.libs) { switch (lib.kind) { case "plankton": { + const directory : string = lib_plankton.string.coin( + "{{directory}}/plankton", + { + "directory": conf.directories.libs, + } + ); /** - * @todo outsource + * @todo do not use "execute" for that */ - const conf = { - "directory": "libs/plankton", - }; - const commands : Array = [ + await execute( lib_plankton.string.coin( "mkdir -p {{directory}}", { - "directory": conf.directory, + "directory": directory, } - ), - lib_plankton.string.coin( - "cd {{directory}}", - { - "directory": conf.directory, - } - ), + ) + ); + await execute( lib_plankton.string.coin( "ptk bundle node {{modules}}", { "modules": lib.data.modules.join(" "), } ), - ]; - for (const command of commands) { - await execute(command); - } + { + "working_directory": directory, + } + ); break; } case "node": { @@ -280,6 +282,9 @@ namespace _munin } ), ]; + /** + * @todo do not use "execute" for that + */ for (const command of commands) { await execute(command); }