UNPKG

656 BJavaScriptView Raw
1'use strict';
2Object.defineProperty(exports, "__esModule", { value: true });
3var fs = require("fs");
4var path = require("path");
5(function findRoot(pth) {
6 var possiblePkgDotJsonPath = path.resolve(String(pth) + '/package.json');
7 try {
8 fs.statSync(possiblePkgDotJsonPath).isFile();
9 console.log(pth);
10 process.exit(0);
11 }
12 catch (err) {
13 var subPath = path.resolve(String(pth) + '/../');
14 if (subPath === pth) {
15 console.error(' => Cannot find path to project root.');
16 process.exit(1);
17 }
18 else {
19 return findRoot(subPath);
20 }
21 }
22})(process.cwd());