Skip to content

Instantly share code, notes, and snippets.

@craigbilner
Created July 23, 2021 15:35
Show Gist options
  • Save craigbilner/f2f8722720247d0c4783a2b39bd0216d to your computer and use it in GitHub Desktop.
Save craigbilner/f2f8722720247d0c4783a2b39bd0216d to your computer and use it in GitHub Desktop.
nx executor
const { exec } = require('child_process');
const { promisify } = require('util');
const path = require('path');
module.exports.default = async function tsc(options, context) {
process.chdir(
path.join(context.cwd, context.workspace.projects[context.projectName].root)
);
try {
const { stdout, stderr } = await promisify(exec)(`tsc -b`);
console.log(stdout);
console.error(stderr);
return { success: stderr === '' };
} catch (e) {
console.error(e.stdout);
}
return { success: false };
};
@maximkoretskiy
Copy link

Nice!
context.cwd could be replaced with contrext.root.
cwd is for your current directory, while root is for project root.
I got stuck with it once and now promoting all around 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment