nx/packages/cli/lib/init-global.ts
Jason Jean e06822da7e
chore(repo): update prettier to v2 (#2934)
this is just for the repo, and not the workspace

Co-authored-by: Rares Matei <matei.rar@gmail.com>
2020-04-29 01:09:37 -04:00

37 lines
871 B
TypeScript

import chalk from 'chalk';
import * as path from 'path';
import { findWorkspaceRoot } from './find-workspace-root';
import { output } from './output';
/**
* Nx is being run from outside a workspace
*/
export function initGlobal() {
const workspace = findWorkspaceRoot(process.cwd());
if (workspace) {
// Found a workspace root - hand off to the local copy of Nx
require(path.join(
workspace.dir,
'node_modules',
'@nrwl',
'cli',
'bin',
'nx.js'
));
} else {
output.log({
title: `The current directory isn't part of an Nx workspace.`,
bodyLines: [
`To create a workspace run:`,
chalk.bold.white(`npx create-nx-workspace@latest <workspace name>`),
],
});
output.note({
title: `For more information please visit https://nx.dev/`,
});
process.exit(0);
}
}