Skip to content

gforceg/tgz-modify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tgz-modify

modify .tgz file entries:

Open ./files/package.tgz. make some changes to package/package.json and remove README.md all together. Then output to a new .tgz file: ./output/package.tgz

const tgz_modify = require('tgz-modify')

tgz_modify('files/package.tgz', 'output/package.tgz', (header, data) => {
  switch(header.name) {
    case 'package/package.json':
      let obj = JSON.parse(data)
      obj.name = 'some-other-project'
      obj.author = 'Some Jerk'
      data = JSON.stringify(obj, null, '\t')
      break;
    case 'package/README.md':
      return null // returning null will skip the file.
  }
  return data
})

// to handle `onFinish` event pass an additional callback
tgz_modify('files/package.tgz', 'output/package.tgz', (h, d) => d, (err) => {})

// or just await a promise
await tgz_modify('files/package.tgz', 'output/package.tgz', ...)

To overwrite the .tgz file, simply use the same filename for the output file:

tgz.modify('./input.tgz', './input.tgz', ...)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published