create-component-template
Version:
Generates react components from templates
39 lines (32 loc) • 878 B
JavaScript
var findUp = require('find-up');
var pkgDir = require('pkg-dir');
var findParentDir = require('find-parent-dir-from-bin');
var path = require('path');
var absDirPath = path.dirname(process.argv[1]);
var currentDirName = path.basename(absDirPath);
var runningFromBin = currentDirName === '.bin';
/**
* gets the module root dir path
* @return {string} moduleRootDir path
*/
var getModuleRootDir = function getModuleRootDir() {
return findUp.sync('create-component-template', {
cwd: __dirname
});
};
/**
* gets the app root dir path
* @return {string} appRootDir path
*/
var getAppRootDir = function getAppRootDir() {
if (runningFromBin) {
return findParentDir(absDirPath);
}
// If not being run as a cli-tool
return pkgDir.sync(__dirname);
};
module.exports = {
getModuleRootDir: getModuleRootDir,
getAppRootDir: getAppRootDir
};
;