资讯专栏INFORMATION COLUMN

一句指令,得到好看的目录树!

junnplus / 2687人阅读

摘要:想要轻松获取目录树字符串吗现在一句话就可以搞定

想要轻松获取目录树字符串吗?现在一句话就可以搞定

moyu/
├── Applications/
├── consolas/
├── Desktop/
├── Documents/
├── Downloads/
├── inttuplus/
├── Library/
├── Movies/
├── Music/
├── my-code/
├── others-code/
├── Pictures/
└── Public/

13 directories, 0 files.

npm i -g print-dir && pdir ~ -m 1

Bash

pdir [.] [-t ./theme.json] [--igd "node,theme"] [--sort dir] [-o ./out.txt] [-m 5]

Package
after npm install print-dir --save

var dirTree  = require("print-dir")

let treeData = dirTree({
    dir: ".",
    theme: {
       "node": "├── ",
       "pipe": "│   ",
       "last": "└── ",
       "indent": "    ",
       "dir_suffix": "/"
    },
    maxLev: 2,
    ignoresFile: [],
    ignoresDir: [],
    prefix: " ",
    isLine: false, // don"t print line by line
    sort: ""
})
/*
 return 
treeData.treeString
treeData.infoString
treeData.fileNum
treeData.dirNum
*/

Default Options

const default_options = {
    t: path.resolve(__dirname, "./themes/default.json"), // theme of char
    _: [process.cwd()],           // directory
    igf: "",                    // ignores files (regular expression matching)
    igd: "",                    // ignores dirs (regular expression matching)
    prefix: "",                 // prefix of each line
    pa: false,                  // print all at once
    sort: ""                    // file sort by "file"/"dir", default is sort by filename.
    // o: "./out.txt"           // store where
    //m: 1                      // max Level 
}

Default Characters

{
    "node": "├── ",
    "pipe": "│   ",
    "last": "└── ",
    "indent": "    ",
    "dir_suffix": "/"
}

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/81296.html

相关文章

  • 太原面经分享:如何在vue面试环节,展示你晋级阿里P6+技术功底?

    摘要:假如你通过阅读源码,掌握了对的实现原理,对生态系统有了充分的认识,那你会在面试环节游刃有余,达到晋级阿里的技术功底,从而提高个人竞争力,面试加分更容易拿。 前言 一年一度紧张刺激的高考开始了,与此同时,我也没闲着,奔走在各大公司的前端面试环节,不断积累着经验,一路升级打怪。 最近两年,太原作为一个准二线城市,各大互联网公司的技术栈也在升级换代,假如你在太原面试前端岗位,而你的技术库里若...

    xiaoqibTn 评论0 收藏0
  • 使用Ghost搭建个人博客

    摘要:使用搭建个人博客作为一个技术人员,一般都会有写一些博客,分享一些文章咱们做技术的就是爱分享。下面我就简单讲解一下在系统下如何使用搭建搭建个人博客网站。 使用Ghost搭建个人博客 作为一个技术人员,一般都会有写一些博客,分享一些文章(咱们做技术的就是爱分享)。因此也诞生了非常多的开源博客系统,比如像wordpress也是目前世界最流行,应用最广的一个天源博客系统,有非常多的插件及模版。...

    Developer 评论0 收藏0

发表评论

0条评论

junnplus

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<