Giter Site home page Giter Site logo

downgoon / cpmd Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 383 KB

copy or move markdown files (supporting wildcard characters) to the destination directory **with their attached images** usually located on sub dir named 'assets' or 'images'.

JavaScript 100.00%
cpmd copy-markdown-file-and-images markdown-images

cpmd's People

Contributors

downgoon avatar wiliam2015 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

cpmd's Issues

批量和move支持?

$ cpmd -s 前缀1-abc.md  -d 前缀专题/
cp images/20181112094421371.png to /Users/downgoon/Documents/markdown/前缀专题/
cp images/20181112095727825.png to /Users/downgoon/Documents/markdown/前缀专题/
cp images/20181112100214339.png to /Users/downgoon/Documents/markdown/前缀专题/
cp images/orders-er.jpg to /Users/downgoon/Documents/markdown/前缀专题/
cp 前缀1-abc.md to /Users/downgoon/Documents/markdown/前缀专题/


$ cpmd -s 前缀2-def.md -d 前缀专题/
cp assets/image-20181121154140531-2786100.png to /Users/downgoon/Documents/markdown/前缀专题/
cp assets/image-20181121154224083-2786144.png to /Users/downgoon/Documents/markdown/前缀专题/
cp assets/image-20181121181058827-2795058.png to /Users/downgoon/Documents/markdown/前缀专题/
cp assets/image-20181121181214371-2795134.png to /Users/downgoon/Documents/markdown/前缀专题/
cp assets/image-20181121175308375-2793988.png to /Users/downgoon/Documents/markdown/前缀专题/
cp assets/image-20181121152713374-2785233.png to /Users/downgoon/Documents/markdown/前缀专题/
cp assets/image-20181121150555166-2783955.png to /Users/downgoon/Documents/markdown/前缀专题/
cp assets/image-20181121151311048-2784391.png to /Users/downgoon/Documents/markdown/前缀专题/
cp 前缀2-def.md to /Users/downgoon/Documents/markdown/前缀专题/

compress images ?

➜  markdown git:(master) which pngmin
pngmin: aliased to source ~/myconf/markdown/pngmin.sh
➜  markdown git:(master) cat ~/myconf/markdown/pngmin.sh
#!/bin/bash
echo "scan large png (1M+) ..."
find $1 -name "*.png" -size +1M
echo "---"
echo "compress ..."
find $1 -name "*.png" -size +1M -exec pngquant -f --ext .png {} \;
echo "---"
echo "after compressed: "
find $1 -name "*.png" -mmin -3
➜  markdown git:(master)

download remote image into local dir

sometimes a markdown file contains lots of images stored at cloud storages such as amazon S3. how to download them and put them in local dir ?

``hexo-style`` images referencing supporting

source files layout

$ tree .
├── README.md
├── assets
│   ├── image-20190708204512742.png

hexo-stype coping

$ cpmd -s README.md -d hexo-blog/source/_post/ --hexo

$ tree hexo-blog/source/_post/ 
├── README
│   └── image-20190708204512742.png
├── README.md

NOTE: The contents of copied file README.md are changed at images referencing.

Merge Request Only Testing

Setting

image

Testing

➜  cpmd git:(master) git status
位于分支 master
您的分支与上游分支 'origin/master' 一致。

尚未暂存以备提交的变更:
  (使用 "git add <文件>..." 更新要提交的内容)
  (使用 "git checkout -- <文件>..." 丢弃工作区的改动)

	修改:     README.md

修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
➜  cpmd git:(master) ✗ git add .
➜  cpmd git:(master) ✗ git commit -m 'Branch protection rule | Include administrators'
[master 6d9b494] Branch protection rule | Include administrators
 1 file changed, 1 deletion(-)
➜  cpmd git:(master)
➜  cpmd git:(master)
➜  cpmd git:(master) git push origin master
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: At least 1 approving review is required by reviewers with write access.
To github.com:downgoon/cpmd.git
 ! [remote rejected] master -> master (protected branch hook declined)
error: 推送一些引用到 '[email protected]:downgoon/cpmd.git' 失败
➜  cpmd git:(master)

remote: error: At least 1 approving review is required by reviewers with write access.

UNKNOWN_VALUE

  • 容易搞错
$ cpmd README.md subdir/
/usr/local/lib/node_modules/cpmd/node_modules/command-line-args/dist/index.js:1345
        throw err
        ^

UNKNOWN_VALUE: Unknown value: README.md
    at commandLineArgs (/usr/local/lib/node_modules/cpmd/node_modules/command-line-args/dist/index.js:1342:21)
    at Object.<anonymous> (/usr/local/lib/node_modules/cpmd/cpmd.js:16:17)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11 {
  name: 'UNKNOWN_VALUE',
  value: 'README.md'
}
  • 正确指令
$ cpmd -s README.md -d subdir/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.