diff --git a/build/main.js b/build/main.js index 9017711..036b537 100644 --- a/build/main.js +++ b/build/main.js @@ -1,3 +1,3 @@ #!/usr/bin/env node -!function(e,r){for(var t in r)e[t]=r[t]}(exports,function(e){var r={};function t(n){if(r[n])return r[n].exports;var u=r[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,t),u.l=!0,u.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var u in e)t.d(n,u,function(r){return e[r]}.bind(null,u));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){e.exports=t(1)},function(e,r,t){"use strict";var n=t(2);Object.defineProperty(r,"__esModule",{value:!0}),r.getPkgProp=function(e,r){if(f.default.nullOrUndefined(e))return null;var t=(0,f.default)(r);try{switch(t){case"undefined":return h(e);case"string":return g(e,r);case"Object":return y(e,r);default:m(!0,{fn:"getPkgProp",message:"Unrecognized argument type"})}}catch(e){m(!0,{fn:"getPkgProp",message:"handler failed",err:e})}},r.handleUndefined=h,r.handleString=g,r.handleObject=y,r.handleError=m,r.getPkgUpJSON=function(){return k.apply(this,arguments)};var u=n(t(3)),a=n(t(4)),o=n(t(5)),i=n(t(6)),f=n(t(7)),c=n(t(8)),l=n(t(9)),s=n(t(10)),d=t(11),p=console.log;function h(e){return b.apply(this,arguments)}function b(){return(b=(0,o.default)(a.default.mark(function e(r){var t;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.default.nullOrUndefined(r)){e.next=2;break}return e.abrupt("return",null);case 2:return e.prev=2,e.next=5,(0,c.default)();case 5:t=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),m(!0,{fn:"handleUndefined",err:e.t0,message:"pkgUp failed"});case 11:return e.abrupt("return",g(r,t));case 12:case"end":return e.stop()}},e,null,[[2,8]])}))).apply(this,arguments)}function g(e){return v.apply(this,arguments)}function v(){return(v=(0,o.default)(a.default.mark(function e(r){var t,n,u,o=arguments;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>1&&void 0!==o[1]?o[1]:process.cwd(),!f.default.nullOrUndefined(r)){e.next=3;break}return e.abrupt("return",null);case 3:return!1===(u=t).endsWith("package.json")&&(u=i.default.resolve(u,"package.json")),e.prev=5,e.next=8,l.default.readJson(u);case 8:n=e.sent,e.next=14;break;case 11:e.prev=11,e.t0=e.catch(5),m(!0,{fn:"handleString",err:e.t0,message:"readJson failed"});case 14:return e.abrupt("return",y(r,n));case 15:case"end":return e.stop()}},e,null,[[5,11]])}))).apply(this,arguments)}function y(e,r){return x.apply(this,arguments)}function x(){return(x=(0,o.default)(a.default.mark(function e(r,t){var n,o;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.default.nullOrUndefined(r)){e.next=2;break}return e.abrupt("return",null);case 2:return o=t,f.default.object(o)&&(!1===o.hasOwnProperty(r)?m(!0,{fn:"handleObject",message:"property not found"}):Object.entries(o).map(function(e){var t=(0,u.default)(e,2),a=t[0],o=t[1];a===r&&(n=o)})),e.abrupt("return",n);case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function m(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=arguments.length>1?arguments[1]:void 0;if(f.default.truthy(e)&&f.default.truthy(r)){var t=r.fn,n=r.err,u=r.message;t&&(0,d.printLine)("red"),f.default.undefined(t)||p("".concat(s.default.red(t))),f.default.undefined(n)||((0,d.printLine)({character:".",color:"grey"}),p("".concat(s.default.red(n))),(0,d.printLine)({character:".",color:"grey"})),f.default.undefined(u)||p("".concat(s.default.grey(u))),(0,d.printLine)("red")}return!1}function k(){return(k=(0,o.default)(a.default.mark(function e(){var r;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,c.default)();case 2:return r=e.sent,e.next=5,l.default.readJson(r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}},function(e,r){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,r){e.exports=require("@babel/runtime/helpers/slicedToArray")},function(e,r){e.exports=require("@babel/runtime/regenerator")},function(e,r){e.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(e,r){e.exports=require("path")},function(e,r){e.exports=require("@sindresorhus/is")},function(e,r){e.exports=require("pkg-up")},function(e,r){e.exports=require("fs-extra")},function(e,r){e.exports=require("chalk")},function(e,r){e.exports=require("tacker")}])); +!function(e,r){for(var t in r)e[t]=r[t]}(exports,function(e){var r={};function t(n){if(r[n])return r[n].exports;var u=r[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,t),u.l=!0,u.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var u in e)t.d(n,u,function(r){return e[r]}.bind(null,u));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){e.exports=t(1)},function(e,r,t){"use strict";var n=t(2);Object.defineProperty(r,"__esModule",{value:!0}),r.getPkgProp=function(e,r){if(f.default.nullOrUndefined(e))return null;var t=(0,f.default)(r);try{switch(t){case"undefined":return b(e);case"string":return g(e,r);case"Object":return v(e,r);default:return m(!0,{fn:"getPkgProp",message:"Unrecognized argument type"})}}catch(e){return m(!0,{fn:"getPkgProp",message:"handler failed",err:e})}},r.handleUndefined=b,r.handleString=g,r.handleObject=v,r.handleError=m,r.getPkgUpJSON=function(){return k.apply(this,arguments)};var u=n(t(3)),a=n(t(4)),i=n(t(5)),o=n(t(6)),f=n(t(7)),c=n(t(8)),l=n(t(9)),s=n(t(10)),d=t(11),p=console.log;function b(e){return h.apply(this,arguments)}function h(){return(h=(0,i.default)(a.default.mark(function e(r){var t;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.default.nullOrUndefined(r)){e.next=2;break}return e.abrupt("return",null);case 2:return e.prev=2,e.next=5,(0,c.default)();case 5:t=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),m(!0,{fn:"handleUndefined",err:e.t0,message:"pkgUp failed"});case 11:return e.abrupt("return",g(r,t));case 12:case"end":return e.stop()}},e,null,[[2,8]])}))).apply(this,arguments)}function g(e){return x.apply(this,arguments)}function x(){return(x=(0,i.default)(a.default.mark(function e(r){var t,n,u,i=arguments;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>1&&void 0!==i[1]?i[1]:process.cwd(),!f.default.nullOrUndefined(r)){e.next=3;break}return e.abrupt("return",null);case 3:return!1===(u=t).endsWith("package.json")&&(u=o.default.resolve(u,"package.json")),e.prev=5,e.next=8,l.default.readJson(u);case 8:n=e.sent,e.next=14;break;case 11:return e.prev=11,e.t0=e.catch(5),e.abrupt("return",m(!0,{fn:"handleString",err:e.t0,message:"readJson failed"}));case 14:return e.abrupt("return",v(r,n));case 15:case"end":return e.stop()}},e,null,[[5,11]])}))).apply(this,arguments)}function v(e,r){return y.apply(this,arguments)}function y(){return(y=(0,i.default)(a.default.mark(function e(r,t){var n,i;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!f.default.nullOrUndefined(r)){e.next=2;break}return e.abrupt("return",null);case 2:if(i=t,!f.default.object(i)){e.next=9;break}if(!1!==i.hasOwnProperty(r)){e.next=8;break}return e.abrupt("return",m(!0,{fn:"handleObject",message:"property not found"}));case 8:Object.entries(i).map(function(e){var t=(0,u.default)(e,2),a=t[0],i=t[1];a===r&&(n=i)});case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}},e)}))).apply(this,arguments)}function m(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=arguments.length>1?arguments[1]:void 0;if(f.default.truthy(e)&&f.default.truthy(r)){var t=r.fn,n=r.err,u=r.message;t&&(0,d.printLine)("red"),f.default.undefined(t)||p("".concat(s.default.red(t))),f.default.undefined(n)||((0,d.printLine)({character:".",color:"grey"}),p("".concat(s.default.red(n))),(0,d.printLine)({character:".",color:"grey"})),f.default.undefined(u)||p("".concat(s.default.grey(u))),(0,d.printLine)("red")}return!1}function k(){return(k=(0,i.default)(a.default.mark(function e(){var r;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,c.default)();case 2:return r=e.sent,e.next=5,l.default.readJson(r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}},function(e,r){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,r){e.exports=require("@babel/runtime/helpers/slicedToArray")},function(e,r){e.exports=require("@babel/runtime/regenerator")},function(e,r){e.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(e,r){e.exports=require("path")},function(e,r){e.exports=require("@sindresorhus/is")},function(e,r){e.exports=require("pkg-up")},function(e,r){e.exports=require("fs-extra")},function(e,r){e.exports=require("chalk")},function(e,r){e.exports=require("tacker")}])); //# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/build/main.js.map b/build/main.js.map index f61c7d8..31fa92b 100644 --- a/build/main.js.map +++ b/build/main.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.js","webpack:///external \"@babel/runtime/helpers/interopRequireDefault\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///external \"path\"","webpack:///external \"@sindresorhus/is\"","webpack:///external \"pkg-up\"","webpack:///external \"fs-extra\"","webpack:///external \"chalk\"","webpack:///external \"tacker\""],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","szProperty","pkg","is","nullOrUndefined","sourceType","_is","handleUndefined","handleString","handleObject","handleError","fn","message","err","_path","_interopRequireDefault","_pkgUp","_fsExtra","_chalk","_tacker","log","console","_callee","pkgPath","_regenerator","wrap","_context","prev","next","abrupt","sent","t0","stop","_callee2","szPkgPath","pkgJSON","_args2","arguments","_context2","length","undefined","process","cwd","endsWith","path","resolve","fs","readJson","_callee3","oPkgJSON","propValue","_context3","entries","map","_ref","_ref2","_slicedToArray2","val","bFlag","oOptions","truthy","printLine","concat","chalk","red","character","color","grey","_callee4","_context4","require"],"mappings":";6DACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QA0DA,OArDAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,S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G,GAAA0C,OAAIC,UAAMC,IAAIrD,KAEdR,UAAGqC,UAAU3B,MAChB,EAAAM,EAAA0C,WAAU,CAAEI,UAAW,IAAKC,MAAO,SACnC9C,EAAG,GAAA0C,OAAIC,UAAMC,IAAInD,MACjB,EAAAM,EAAA0C,WAAU,CAAEI,UAAW,IAAKC,MAAO,UAEhC/D,UAAGqC,UAAU5B,IAChBQ,EAAG,GAAA0C,OAAIC,UAAMI,KAAKvD,MAEpB,EAAAO,EAAA0C,WAAU,OAEZ,OAAO,qDAGF,SAAAO,IAAA,IAAA7C,EAAA,OAAAC,EAAA,QAAAC,KAAA,SAAA4C,GAAA,cAAAA,EAAA1C,KAAA0C,EAAAzC,MAAA,cAAAyC,EAAAzC,KAAA,GACe,EAAAZ,EAAA,WADf,cACDO,EADC8C,EAAAvC,KAAAuC,EAAAzC,KAAA,EAEQkB,UAAGC,SAASxB,GAFpB,cAAA8C,EAAAxC,OAAA,SAAAwC,EAAAvC,MAAA,wBAAAuC,EAAArC,SAAAoC,6CCpGPpG,EAAAD,QAAAuG,QAAA,+DCAAtG,EAAAD,QAAAuG,QAAA,uDCAAtG,EAAAD,QAAAuG,QAAA,6CCAAtG,EAAAD,QAAAuG,QAAA,0DCAAtG,EAAAD,QAAAuG,QAAA,uBCAAtG,EAAAD,QAAAuG,QAAA,mCCAAtG,EAAAD,QAAAuG,QAAA,yBCAAtG,EAAAD,QAAAuG,QAAA,2BCAAtG,EAAAD,QAAAuG,QAAA,wBCAAtG,EAAAD,QAAAuG,QAAA","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","const log = console.log;\nimport path from \"path\";\nimport is from \"@sindresorhus/is\";\nimport pkgUp from \"pkg-up\";\nimport fs from \"fs-extra\";\nimport chalk from \"chalk\";\nimport { printLine, printMirror } from \"tacker\";\n\nexport function getPkgProp(szProperty, pkg) {\n if (is.nullOrUndefined(szProperty)) return null;\n let sourceType = is(pkg);\n try {\n switch (sourceType) {\n case \"undefined\":\n return handleUndefined(szProperty);\n case \"string\":\n return handleString(szProperty, pkg);\n case \"Object\":\n return handleObject(szProperty, pkg);\n default:\n handleError(true, {\n fn: \"getPkgProp\",\n message: \"Unrecognized argument type\"\n });\n }\n } catch (err) {\n handleError(true, { fn: \"getPkgProp\", message: \"handler failed\", err });\n }\n}\n\nexport async function handleUndefined(szProperty) {\n if (is.nullOrUndefined(szProperty)) return null;\n let pkgPath;\n try {\n pkgPath = await pkgUp();\n } catch (err) {\n handleError(true, { fn: \"handleUndefined\", err, message: \"pkgUp failed\" });\n }\n return handleString(szProperty, pkgPath);\n}\n\nexport async function handleString(szProperty, szPkgPath = process.cwd()) {\n if (is.nullOrUndefined(szProperty)) return null;\n let pkgJSON,\n pkgPath = szPkgPath;\n if (pkgPath.endsWith(\"package.json\") === false) {\n pkgPath = path.resolve(pkgPath, \"package.json\");\n }\n try {\n pkgJSON = await fs.readJson(pkgPath);\n } catch (err) {\n handleError(true, { fn: \"handleString\", err, message: \"readJson failed\" });\n }\n //TODO: check if pkgPath exists\n //TODO: add path-exists\n return handleObject(szProperty, pkgJSON);\n}\n\nexport async function handleObject(szProperty, oPkgJSON) {\n if (is.nullOrUndefined(szProperty)) return null;\n let propValue;\n let pkgJSON = oPkgJSON;\n if (is.object(pkgJSON)) {\n if (pkgJSON.hasOwnProperty(szProperty) === false) {\n handleError(true, { fn: \"handleObject\", message: \"property not found\" });\n } else {\n //? Feel like there's a better way to grab this value than iterating\n Object.entries(pkgJSON).map(([key, val]) => {\n if (key === szProperty) {\n propValue = val;\n }\n });\n }\n }\n return propValue;\n}\n\nexport function handleError(bFlag = true, oOptions) {\n if (is.truthy(bFlag) && is.truthy(oOptions)) {\n let { fn, err, message } = oOptions;\n if (fn)\n //TODO: Move to tacker\n //TODO: Add initial undefined & emptyString check. Then concat all instead of piecemeal\n printLine(\"red\");\n if (!is.undefined(fn)) {\n log(`${chalk.red(fn)}`);\n }\n if (!is.undefined(err)) {\n printLine({ character: \".\", color: \"grey\" });\n log(`${chalk.red(err)}`);\n printLine({ character: \".\", color: \"grey\" });\n }\n if (!is.undefined(message)) {\n log(`${chalk.grey(message)}`);\n }\n printLine(\"red\");\n }\n return false;\n}\n\nexport async function getPkgUpJSON() {\n let pkgPath = await pkgUp();\n return await fs.readJson(pkgPath);\n}\n\n// function initTest() {\n// let lgPath = path.resolve(process.cwd(), \"sandbox\", \"library-genesis\");\n// (async () => {\n// let x = await handleUndefined(\"name\"); //\n// printMirror({ x }, \"magenta\", \"grey\");\n\n// let lgObj = await fs.readJson(path.join(lgPath, \"package.json\"));\n// let y = await handleString(\"name\", lgPath);\n// let z = await handleObject(\"name\", lgObj);\n// printMirror({ y }, \"magenta\", \"grey\");\n// printMirror({ z }, \"magenta\", \"grey\");\n// // x;\n// // y;\n// let a = await getPkgProp(\"name\");\n// let b = await getPkgProp(\"name\", lgPath);\n// let c = await getPkgProp(\"name\", lgObj);\n// // a;\n// // b;\n// // c;\n// })();\n// }\n// initTest()\n","module.exports = require(\"@babel/runtime/helpers/interopRequireDefault\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","module.exports = require(\"path\");","module.exports = require(\"@sindresorhus/is\");","module.exports = require(\"pkg-up\");","module.exports = require(\"fs-extra\");","module.exports = require(\"chalk\");","module.exports = require(\"tacker\");"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.js","webpack:///external \"@babel/runtime/helpers/interopRequireDefault\"","webpack:///external \"@babel/runtime/helpers/slicedToArray\"","webpack:///external \"@babel/runtime/regenerator\"","webpack:///external \"@babel/runtime/helpers/asyncToGenerator\"","webpack:///external \"path\"","webpack:///external \"@sindresorhus/is\"","webpack:///external \"pkg-up\"","webpack:///external \"fs-extra\"","webpack:///external \"chalk\"","webpack:///external \"tacker\""],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","szProperty","pkg","is","nullOrUndefined","sourceType","_is","handleUndefined","handleString","handleObject","handleError","fn","message","err","_path","_interopRequireDefault","_pkgUp","_fsExtra","_chalk","_tacker","log","console","_callee","pkgPath","_regenerator","wrap","_context","prev","next","abrupt","sent","t0","stop","_callee2","szPkgPath","pkgJSON","_args2","arguments","_context2","length","undefined","process","cwd","endsWith","path","resolve","fs","readJson","_callee3","oPkgJSON","propValue","_context3","entries","map","_ref","_ref2","_slicedToArray2","val","bFlag","oOptions","truthy","printLine","concat","chalk","red","character","color","grey","_callee4","_context4","require"],"mappings":";6DACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QA0DA,OArDAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK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GAAA0C,OAAIC,UAAMC,IAAIrD,KAEdR,UAAGqC,UAAU3B,MAChB,EAAAM,EAAA0C,WAAU,CAAEI,UAAW,IAAKC,MAAO,SACnC9C,EAAG,GAAA0C,OAAIC,UAAMC,IAAInD,MACjB,EAAAM,EAAA0C,WAAU,CAAEI,UAAW,IAAKC,MAAO,UAEhC/D,UAAGqC,UAAU5B,IAChBQ,EAAG,GAAA0C,OAAIC,UAAMI,KAAKvD,MAEpB,EAAAO,EAAA0C,WAAU,OAEZ,OAAO,qDAGF,SAAAO,IAAA,IAAA7C,EAAA,OAAAC,EAAA,QAAAC,KAAA,SAAA4C,GAAA,cAAAA,EAAA1C,KAAA0C,EAAAzC,MAAA,cAAAyC,EAAAzC,KAAA,GACe,EAAAZ,EAAA,WADf,cACDO,EADC8C,EAAAvC,KAAAuC,EAAAzC,KAAA,EAEQkB,UAAGC,SAASxB,GAFpB,cAAA8C,EAAAxC,OAAA,SAAAwC,EAAAvC,MAAA,wBAAAuC,EAAArC,SAAAoC,6CC/GPpG,EAAAD,QAAAuG,QAAA,+DCAAtG,EAAAD,QAAAuG,QAAA,uDCAAtG,EAAAD,QAAAuG,QAAA,6CCAAtG,EAAAD,QAAAuG,QAAA,0DCAAtG,EAAAD,QAAAuG,QAAA,uBCAAtG,EAAAD,QAAAuG,QAAA,mCCAAtG,EAAAD,QAAAuG,QAAA,yBCAAtG,EAAAD,QAAAuG,QAAA,2BCAAtG,EAAAD,QAAAuG,QAAA,wBCAAtG,EAAAD,QAAAuG,QAAA","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","const log = console.log;\nimport path from \"path\";\nimport is from \"@sindresorhus/is\";\nimport pkgUp from \"pkg-up\";\nimport fs from \"fs-extra\";\nimport chalk from \"chalk\";\nimport { printLine, printMirror } from \"tacker\";\n\nexport function getPkgProp(szProperty, pkg) {\n if (is.nullOrUndefined(szProperty)) return null;\n let sourceType = is(pkg);\n try {\n switch (sourceType) {\n case \"undefined\":\n return handleUndefined(szProperty);\n case \"string\":\n return handleString(szProperty, pkg);\n case \"Object\":\n return handleObject(szProperty, pkg);\n default:\n return handleError(true, {\n fn: \"getPkgProp\",\n message: \"Unrecognized argument type\"\n });\n }\n } catch (err) {\n return handleError(true, {\n fn: \"getPkgProp\",\n message: \"handler failed\",\n err\n });\n }\n}\n\nexport async function handleUndefined(szProperty) {\n if (is.nullOrUndefined(szProperty)) return null;\n let pkgPath;\n try {\n pkgPath = await pkgUp();\n } catch (err) {\n handleError(true, { fn: \"handleUndefined\", err, message: \"pkgUp failed\" });\n }\n return handleString(szProperty, pkgPath);\n}\n\nexport async function handleString(szProperty, szPkgPath = process.cwd()) {\n if (is.nullOrUndefined(szProperty)) return null;\n let pkgJSON,\n pkgPath = szPkgPath;\n if (pkgPath.endsWith(\"package.json\") === false) {\n pkgPath = path.resolve(pkgPath, \"package.json\");\n }\n try {\n pkgJSON = await fs.readJson(pkgPath);\n } catch (err) {\n return handleError(true, {\n fn: \"handleString\",\n err,\n message: \"readJson failed\"\n });\n }\n //TODO: check if pkgPath exists\n //TODO: add path-exists\n return handleObject(szProperty, pkgJSON);\n}\n\nexport async function handleObject(szProperty, oPkgJSON) {\n if (is.nullOrUndefined(szProperty)) return null;\n let propValue;\n let pkgJSON = oPkgJSON;\n if (is.object(pkgJSON)) {\n if (pkgJSON.hasOwnProperty(szProperty) === false) {\n return handleError(true, {\n fn: \"handleObject\",\n message: \"property not found\"\n });\n } else {\n //? Feel like there's a better way to grab this value than iterating\n Object.entries(pkgJSON).map(([key, val]) => {\n if (key === szProperty) {\n propValue = val;\n }\n });\n }\n }\n return propValue;\n}\n\nexport function handleError(bFlag = true, oOptions) {\n if (is.truthy(bFlag) && is.truthy(oOptions)) {\n let { fn, err, message } = oOptions;\n if (fn)\n //TODO: Move to tacker\n //TODO: Add initial undefined & emptyString check. Then concat all instead of piecemeal\n printLine(\"red\");\n if (!is.undefined(fn)) {\n log(`${chalk.red(fn)}`);\n }\n if (!is.undefined(err)) {\n printLine({ character: \".\", color: \"grey\" });\n log(`${chalk.red(err)}`);\n printLine({ character: \".\", color: \"grey\" });\n }\n if (!is.undefined(message)) {\n log(`${chalk.grey(message)}`);\n }\n printLine(\"red\");\n }\n return false;\n}\n\nexport async function getPkgUpJSON() {\n let pkgPath = await pkgUp();\n return await fs.readJson(pkgPath);\n}\n\n// function initTest() {\n// let lgPath = path.resolve(process.cwd(), \"sandbox\", \"library-genesis\");\n// (async () => {\n// let x = await handleUndefined(\"name\"); //\n// printMirror({ x }, \"magenta\", \"grey\");\n\n// let lgObj = await fs.readJson(path.join(lgPath, \"package.json\"));\n// let y = await handleString(\"name\", lgPath);\n// let z = await handleObject(\"name\", lgObj);\n// printMirror({ y }, \"magenta\", \"grey\");\n// printMirror({ z }, \"magenta\", \"grey\");\n// // x;\n// // y;\n// let a = await getPkgProp(\"name\");\n// let b = await getPkgProp(\"name\", lgPath);\n// let c = await getPkgProp(\"name\", lgObj);\n// // a;\n// // b;\n// // c;\n// })();\n// }\n// initTest()\n","module.exports = require(\"@babel/runtime/helpers/interopRequireDefault\");","module.exports = require(\"@babel/runtime/helpers/slicedToArray\");","module.exports = require(\"@babel/runtime/regenerator\");","module.exports = require(\"@babel/runtime/helpers/asyncToGenerator\");","module.exports = require(\"path\");","module.exports = require(\"@sindresorhus/is\");","module.exports = require(\"pkg-up\");","module.exports = require(\"fs-extra\");","module.exports = require(\"chalk\");","module.exports = require(\"tacker\");"],"sourceRoot":""} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 463b32e..64dcec7 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ import fs from "fs-extra"; import chalk from "chalk"; import { printLine, printMirror } from "tacker"; +//TODO: Add option object which will accept handleError args export function getPkgProp(szProperty, pkg) { if (is.nullOrUndefined(szProperty)) return null; let sourceType = is(pkg); diff --git a/tests/handle.test.js b/tests/handle.test.js index 042c927..c3a605a 100644 --- a/tests/handle.test.js +++ b/tests/handle.test.js @@ -77,14 +77,6 @@ test(`${chalk.cyan("handleError")} returns false`, t => { t.false(handleError(false)); }); -test(`${chalk.cyan( - "getPkgProp" -)} returns undefined when trying to grab ${chalk.underline( - "xyz" -)} property`, async t => { - t.true(is.nullOrUndefined(await getPkgProp("xyz"))); -}); - test(`${chalk.cyan("getPkgProp")} returns an ${chalk.underline( "object" )}`, async t => { @@ -94,3 +86,9 @@ test(`${chalk.cyan("getPkgProp")} returns an ${chalk.underline( }; t.deepEqual(await getPkgProp("repository"), expectedRepoProp); }); + +test(`${chalk.cyan( + "getPkgProp" +)} returns false when property isn't found`, async t => { + t.false(await getPkgProp("doesntexist")); +});