UNPKG

@naxodev/gonx

Version:

Modern Nx plugin to use Go in a Nx workspace

33 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getGoModules = void 0; const child_process_1 = require("child_process"); /** * Executes the `go list -m -json` command in the * specified directory and returns the output as a string. * * @param cwd the current working directory where the command should be executed. * @param failSilently if true, the function will return an empty string instead of throwing an error when the command fails. * @returns The output of the `go list -m -json` command as a string. * @throws Will throw an error if the command fails and `failSilently` is false. */ const getGoModules = (cwd, failSilently) => { try { return (0, child_process_1.execSync)('go list -m -json', { encoding: 'utf-8', cwd, stdio: ['ignore'], windowsHide: true, }); } catch (error) { if (failSilently) { return ''; } else { throw error; } } }; exports.getGoModules = getGoModules; //# sourceMappingURL=get-go-modules.js.map