UNPKG

1.96 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/utils.js"],"names":["resolvePath","isPathExist","findPathThatExist","getWebpackConfigByPath","currentPath","Error","resolve","process","cwd","targetPath","statSync","err","code","paths","find","currectPath","require","default"],"mappings":";;;;;QAGgBA,W,GAAAA,W;QAQAC,W,GAAAA,W;QAUAC,iB,GAAAA,iB;QAIAC,sB,GAAAA,sB;;AAzBhB;;;;AACA;;;;;;AAEO,SAASH,WAAT,GAAuC;AAAA,MAAlBI,WAAkB,uEAAJ,EAAI;;AAC5C,MAAI,OAAOA,WAAP,KAAuB,QAA3B,EAAqC;AACnC,UAAM,IAAIC,KAAJ,CAAU,2BAAV,CAAN;AACD;;AAED,SAAO,eAAKC,OAAL,CAAaC,QAAQC,GAAR,EAAb,EAA4BJ,WAA5B,CAAP;AACD;;AAEM,SAASH,WAAT,CAAqBQ,UAArB,EAAiC;AACtC,MAAI;AACF,iBAAGC,QAAH,CAAYD,UAAZ;AACD,GAFD,CAEE,OAAOE,GAAP,EAAY;AACZ,WAAOA,IAAIC,IAAJ,KAAa,QAApB;AACD;;AAED,SAAO,IAAP;AACD;;AAEM,SAASV,iBAAT,GAAqC;AAAA,oCAAPW,KAAO;AAAPA,SAAO;AAAA;;AAC1C,SAAOA,MAAMC,IAAN,CAAW;AAAA,WAAeb,YAAYc,WAAZ,CAAf;AAAA,GAAX,CAAP;AACD;;AAEM,SAASZ,sBAAT,GAAkD;AAAA,MAAlBC,WAAkB,uEAAJ,EAAI;;AACvD,MAAI,OAAOA,WAAP,KAAuB,QAA3B,EAAqC;AACnC,UAAM,IAAIC,KAAJ,CAAU,2BAAV,CAAN;AACD;;AAED;AACAW,UAAQ,gBAAR;;AAEA,SAAOA,QAAQZ,WAAR,EAAqBa,OAA5B;AACA;AACD","file":"utils.js","sourcesContent":["import path from 'path'\nimport fs from 'fs'\n\nexport function resolvePath(currentPath = '') {\n if (typeof currentPath !== 'string') {\n throw new Error('currentPath is not string')\n }\n\n return path.resolve(process.cwd(), currentPath)\n}\n\nexport function isPathExist(targetPath) {\n try {\n fs.statSync(targetPath)\n } catch (err) {\n return err.code !== 'ENOENT'\n }\n\n return true\n}\n\nexport function findPathThatExist(...paths) {\n return paths.find(currectPath => isPathExist(currectPath))\n}\n\nexport function getWebpackConfigByPath(currentPath = '') {\n if (typeof currentPath !== 'string') {\n throw new Error('currentPath is not string')\n }\n\n /* eslint-disable global-require, import/no-dynamic-require */\n require('babel-register')\n\n return require(currentPath).default;\n /* eslint-enable */\n}\n"]}
\No newline at end of file