UNPKG

custom-app

Version:

ITIMS��Ʒ�鿪��ר��React���,�Dz��ý��ּ�dhcc-app���������

95 lines (79 loc) 2.62 kB
const path = require('path') const fs = require('fs-extra') function getReactAppPath (currentPath) { let result = currentPath.substring(0, currentPath.lastIndexOf("reactapp")) console.log(result) return path.join(result, 'reactapp'); // var mypath = require('../lib/rootpath/path').path; // if (mypath == "" || !mypath) { // currentPath = currentPath || process.cwd() // let p1 = path.join(currentPath, 'src/main/reactapp') // let p2 = path.join(currentPath, 'main/reactapp') // let p3 = path.join(currentPath, 'reactapp') // if (fs.existsSync(p1)) { // return p1; // } else if (fs.existsSync(p2)) { // return p2; // } else if (fs.existsSync(p3)) { // return p3; // } else { // let p4 = currentPath.substring(0, currentPath.indexOf('main')); // return path.join(p4, 'main', 'reactapp') // } // } else { // mypath = mypath.split(",").join("/") // return mypath; // } } exports.getReactAppPath = getReactAppPath; function getOriginalReactAppPath (currentPath) { var mypath = require('../lib/rootpath/original').path; if (mypath == "" || !mypath) { currentPath = currentPath || process.cwd() let p1 = path.join(currentPath, 'src/main/reactapp') let p2 = path.join(currentPath, 'main/reactapp') let p3 = path.join(currentPath, 'reactapp') if (fs.existsSync(p1)) { return p1; } else if (fs.existsSync(p2)) { return p2; } else if (fs.existsSync(p3)) { return p3; } else { let p4 = currentPath.substring(0, currentPath.indexOf('main')); return path.join(p4, 'main', 'reactapp') } } else { mypath = mypath.replace('.,', '').split(",").join("/") return mypath; } } exports.getOriginalReactAppPath = getOriginalReactAppPath; function getIgnorePath () { var mypath = require('../lib/rootpath/ignore').path; if (mypath == "" || !mypath) { return ''; } else { mypath = mypath.replace('.,', '').split(",").join("/") return mypath; } } exports.getIgnorePath = getIgnorePath; function isPlugin (reactapp, projectName) { let result = false; const target = path.join(reactapp, 'src', projectName, 'package.json') try { let packageJson = require(target) if (packageJson) { let moduleType = packageJson.moduleType if (moduleType && moduleType == 'plugin') { result = true } } } catch (error) { console.error(error) result = false } return result; } exports.isPlugin = isPlugin;