Last active
April 8, 2018 02:31
-
-
Save isaacs/8142efc45eef5109e1d128588f08aebe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree x | |
x | |
└── y/ | |
└── z/ | |
└── .gitignore | |
2 directories, 1 file | |
$ tar cf x.tar x | |
$ tar tvf x.tar | |
drwxr-xr-x 0 isaacs staff 0 Aug 17 16:47 x/ | |
drwxr-xr-x 0 isaacs staff 0 Aug 17 16:46 x/y/ | |
drwxr-xr-x 0 isaacs staff 0 Aug 17 16:46 x/y/z/ | |
-rw-r--r-- 0 isaacs staff 0 Aug 17 16:46 x/y/z/.gitignore | |
$ node rename.js | |
$ tree output/ | |
output/ | |
└── x/ | |
└── y/ | |
└── z/ | |
└── .npmignore | |
3 directories, 1 file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const tar = require('./') | |
const file = 'x.tar' | |
const mkdirp = require('mkdirp') | |
const path = require('path') | |
const rimraf = require('rimraf') | |
rimraf.sync('output') | |
mkdirp.sync('output') | |
tar.x({ | |
file: file, | |
cwd: 'output', | |
onentry: entry => { | |
if (path.basename(entry.path) === '.gitignore') | |
entry.path = path.dirname(entry.path) + '/.npmignore' | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment