ggcp

git-glob-copy — glob-aware two-way copying for git

Release Maintainability Test Coverage

Requirements

  • Node.js >= 16

Install

npm i git-glob-cp

# or as a global package
npm i -g ggcp

Usage

To perform various repos automations: bulk config reading, cascade template updating, etc.

CLI

# Copy `json` files from `master` branch of remote repo to local dir `temp`
git-glob-copy [email protected]:antongolub/tsc-esm-fix.git/master/*.json temp


# Push `json` files from local `.` dir to remote `json` branch
git-glob-copy *.json [email protected]:antongolub/tsc-esm-fix.git/master/json


# Push from repo to repo
ggcp '[email protected]:antongolub/tsc-esm-fix.git/master/foo/*.txt' [email protected]:antongolub/git-glob-copy.git/master/bar

ggcp is an alias for git-glob-copy

Flag Description Default
--message -m Commit message chore: sync
--version -v Print version
--help -h Show help
--ignore-files -i Path to ignoreFile (like .gitignore or .npmignore)

Pattern examples

// Absolute dir path
'/foo/bar'

// Rel paths
'./foo/bar'
'foo/bar'

// Any depth md-filter
'./**/*.md'

// git://, [email protected], ssh://, https:// refs
'https://github.com/antongolub/tsc-esm-fix.git/master/*.json'
'ssh://github.com/antongolub/git-glob-cp.git/test/test'
'[email protected]:antongolub/git-glob-cp.git/master/foo/bar/**/*.js'
'git://github.com/antongolub/git-glob-cp.git/some-branch-name/test/**/*.js'
// repo ref                                 // branch        // glob pattern

JS API

import { copy, sync } from 'ggcp'

const from = '[email protected]:antongolub/tsc-esm-fix.git/master/*.json'
const to = 'temp'
const msg = 'updated'
const ignoreFiles = '.gitignore'

// Copy any to any
await copy(from, to, msg, ignoreFiles)

// Synchronizes dirs only
await copydir({
  from,       // Relative dir / glob pattern(s)
  baseFrom,   // Base dir. Defaults to process.cwd()
  to,         // Rel path.
  baseTo,     // Base dir. Defaults to process.cwd()
  debug,      // Debugger. Defauts to noop
  ignoreFiles // Glob patterns to look for ignore files. string | string[]
})

License

MIT

GitHub

View Github