@wrote/read-dir-structure
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -0,1 +1,7 @@ | ||
## 3 February 2019 | ||
### [1.3.1](https://github.com/wrote/read-dir-structure/compare/v1.3.0...v1.3.1) | ||
- [fix] Update `makePromise`. | ||
## 25 November 2019 | ||
@@ -2,0 +8,0 @@ |
@@ -5,7 +5,7 @@ #!/usr/bin/env node | ||
const path = require('path'); | ||
const os = require('os'); const {lstat:l,readdir:p}=fs;const q=(a,b=0,e=!1)=>{if(0===b&&!e)return a;a=a.split("\n",e?b+1:void 0);return e?a[a.length-1]:a.slice(b).join("\n")},r=(a,b=!1)=>q(a,2+(b?1:0)),t=a=>{({callee:{caller:a}}=a);return a};const {homedir:u}=os;const v=/\s+at.*(?:\(|\s)(.*)\)?/,w=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/,x=u(),y=a=>{const {pretty:b=!1,ignoredModules:e=["pirates"]}={},f=e.join("|"),d=new RegExp(w.source.replace("IGNORED_MODULES",f));return a.replace(/\\/g,"/").split("\n").filter(c=>{c=c.match(v);if(null===c||!c[1])return!0;c=c[1];return c.includes(".app/Contents/Resources/electron.asar")||c.includes(".app/Contents/Resources/default_app.asar")?!1:!d.test(c)}).filter(c=> | ||
c.trim()).map(c=>b?c.replace(v,(g,h)=>g.replace(h,h.replace(x,"~"))):c).join("\n")};function z(a,b,e=!1){return function(f){var d=t(arguments),{stack:c}=Error();const g=q(c,2,!0),h=(c=f instanceof Error)?f.message:f;d=[`Error: ${h}`,...null!==d&&a===d||e?[b]:[g,b]].join("\n");d=y(d);return Object.assign(c?f:Error(),{message:h,stack:d})}};function A(a){var {stack:b}=Error();const e=t(arguments);b=r(b,a);return z(e,b,a)};function B(a,b){if(b>a-2)throw Error("Function does not accept that many arguments.");}async function C(a,b,e){const f=A(!0);if("function"!==typeof a)throw Error("Function must be passed.");const {length:d}=a;if(!d)throw Error("Function does not accept any arguments.");return await new Promise((c,g)=>{const h=(k,m)=>k?(k=f(k),g(k)):c(e||m);let n=[h];Array.isArray(b)?(b.forEach((k,m)=>{B(d,m)}),n=[...b,h]):1<Array.from(arguments).length&&(B(d,0),n=[b,h]);a(...n)})};const {join:D,relative:E}=path;async function F(a,b){b=b.map(async e=>{const f=D(a,e);return{lstat:await C(l,f),path:f,relativePath:e}});return await Promise.all(b)}const G=a=>a.lstat.isDirectory(),H=a=>!a.lstat.isDirectory(); | ||
async function I(a,b={}){if(!a)throw Error("Please specify a path to the directory");const {ignore:e=[]}=b;if(!(await C(l,a)).isDirectory())throw b=Error("Path is not a directory"),b.code="ENOTDIR",b;b=await C(p,a);var f=await F(a,b);b=f.filter(G);f=f.filter(H).reduce((d,c)=>{var g=c.lstat.isDirectory()?"Directory":c.lstat.isFile()?"File":c.lstat.isSymbolicLink()?"SymbolicLink":void 0;return{...d,[c.relativePath]:{type:g}}},{});b=await b.reduce(async(d,{path:c,relativePath:g})=>{const h=E(a,c);if(e.includes(h))return d; | ||
d=await d;c=await I(c);return{...d,[g]:c}},{});return{content:{...f,...b},type:"Directory"}}const J=(a,b)=>{let e=[],f=[];Object.keys(a).forEach(c=>{const {type:g}=a[c];"File"==g?e.push(D(b,c)):"Directory"==g&&f.push(c)});const d=f.reduce((c,g)=>{const {content:h}=a[g];g=J(h,D(b,g));return[...c,...g]},[]);return[...e,...d]};module.exports={_readDirStructure:I,_getFiles:J}; | ||
const os = require('os'); const l=fs.lstat,m=fs.readdir;const n=(a,b=0,d=!1)=>{if(0===b&&!d)return a;a=a.split("\n",d?b+1:void 0);return d?a[a.length-1]:a.slice(b).join("\n")},p=(a,b=!1)=>n(a,2+(b?1:0)),q=a=>{({callee:{caller:a}}=a);return a};const r=os.homedir;const t=/\s+at.*(?:\(|\s)(.*)\)?/,u=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/,v=r(),w=a=>{const {pretty:b=!1,ignoredModules:d=["pirates"]}={},e=d.join("|"),f=new RegExp(u.source.replace("IGNORED_MODULES",e));return a.replace(/\\/g,"/").split("\n").filter(c=>{c=c.match(t);if(null===c||!c[1])return!0;c=c[1];return c.includes(".app/Contents/Resources/electron.asar")||c.includes(".app/Contents/Resources/default_app.asar")?!1:!f.test(c)}).filter(c=> | ||
c.trim()).map(c=>b?c.replace(t,(g,h)=>g.replace(h,h.replace(v,"~"))):c).join("\n")};function x(a,b,d=!1){return function(e){var f=q(arguments),{stack:c}=Error();const g=n(c,2,!0),h=(c=e instanceof Error)?e.message:e;f=[`Error: ${h}`,...null!==f&&a===f||d?[b]:[g,b]].join("\n");f=w(f);return Object.assign(c?e:Error(),{message:h,stack:f})}};function y(a){var {stack:b}=Error();const d=q(arguments);b=p(b,a);return x(d,b,a)};async function z(a,b,d){const e=y(!0);if("function"!=typeof a)throw Error("Function must be passed.");if(!a.length)throw Error(`Function${a.name?` ${a.name}`:""} does not accept any arguments.`);return await new Promise((f,c)=>{const g=(k,D)=>k?(k=e(k),c(k)):f(d||D);let h=[g];Array.isArray(b)?h=[...b,g]:1<Array.from(arguments).length&&(h=[b,g]);a(...h)})};const A=path.join,B=path.relative;async function C(a,b){b=b.map(async d=>{const e=A(a,d);return{lstat:await z(l,e),path:e,relativePath:d}});return await Promise.all(b)}const E=a=>a.lstat.isDirectory(),F=a=>!a.lstat.isDirectory(); | ||
async function G(a,b={}){if(!a)throw Error("Please specify a path to the directory");const {ignore:d=[]}=b;if(!(await z(l,a)).isDirectory())throw b=Error("Path is not a directory"),b.code="ENOTDIR",b;b=await z(m,a);var e=await C(a,b);b=e.filter(E);e=e.filter(F).reduce((f,c)=>{var g=c.lstat.isDirectory()?"Directory":c.lstat.isFile()?"File":c.lstat.isSymbolicLink()?"SymbolicLink":void 0;return{...f,[c.relativePath]:{type:g}}},{});b=await b.reduce(async(f,{path:c,relativePath:g})=>{const h=B(a,c);if(d.includes(h))return f; | ||
f=await f;c=await G(c);return{...f,[g]:c}},{});return{content:{...e,...b},type:"Directory"}}const H=(a,b)=>{let d=[],e=[];Object.keys(a).forEach(c=>{const {type:g}=a[c];"File"==g?d.push(A(b,c)):"Directory"==g&&e.push(c)});const f=e.reduce((c,g)=>{const {content:h}=a[g];g=H(h,A(b,g));return[...c,...g]},[]);return[...d,...f]};module.exports={_readDirStructure:G,_getFiles:H}; | ||
//# sourceMappingURL=depack.js.map |
{ | ||
"name": "@wrote/read-dir-structure", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Reads directory structure.", | ||
@@ -15,3 +15,3 @@ "main": "compile/index.js", | ||
"lint": "eslint .", | ||
"compile": "depack src/depack -o compile/depack.js -a -c -s", | ||
"lib": "depack src/depack -o compile/depack.js -a -c -s", | ||
"doc": "NODE_DEBUG=doc doc -o README.md -n _wrote", | ||
@@ -61,9 +61,9 @@ "d": "yarn-s template d1 externs", | ||
"devDependencies": { | ||
"alamode": "^3.2.0", | ||
"documentary": "^1.34.1", | ||
"alamode": "^3.3.2", | ||
"documentary": "^1.35.10", | ||
"eslint-config-artdeco": "1.0.1", | ||
"makepromise": "^3.1.0", | ||
"yarn-s": "1.1.0", | ||
"zoroaster": "^4.1.2" | ||
"makepromise": "^3.2.0", | ||
"yarn-s": "1.2.3", | ||
"zoroaster": "^4.2.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39971
564