Skip to main content

g2d

Test Release ghcr

Transform .gitignore into .dockerignore.

.gitignore .dockerignore
!/ !
! !**/
/ -
- **/

Download

Check releases.

Usage

g2d will detect the nearest .gitignore by default.

# stdout
g2d

# specific file
g2d foo/.gitignore

# export to ./.dockerignore
g2d -o .

# if foo is a directory
# .dockerignore would be exported to foo/.dockerignore
g2d -o foo
cat foo/.gitignore

# if foo is a file
# .dockerignore would be exported to foo
g2d -o foo
cat foo

# from stdin to stdout
cat .gitignore | g2d > .dockerignore

# more
g2d -h

Install with Deno

# install from remote
deno install \
  --unstable \
  --allow-read \
  --allow-write \
  -n g2d \
  https://deno.land/x/g2d/bin.ts

# install from local repo
git clone git@github.com:VdustR/g2d.git
deno install \
  --unstable \
  --allow-read \
  --allow-write \
  -n g2d \
  bin.ts

# uninstall
rm $(which g2d)

Deno Library

import g2b from "https://deno.land/x/g2d/mod.ts";

const gitignore = Deno.readTextFileSync(".gitignore");
const dockerignore = g2b(gitignore);
Deno.writeTextFileSync(".dockerignore", dockerignore);

Container

Check g2d container.

podman run --rm -it -v $(pwd):/repo g2d g2d /repo/.gitignore -o /repo

Dev

deno run --unstable --allow-read --allow-write bin.ts

Test

./scripts/test.sh

Tested Dev Env

deno 1.19.1 (release, x86_64-unknown-linux-gnu)
v8 9.9.115.7
typescript 4.5.2

License

MIT