Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tar-compress-cli

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tar-compress-cli - npm Package Compare versions

Comparing version 0.0.6 to 0.1.0

.travis.yml

17

package.json
{
"name": "tar-compress-cli",
"version": "0.0.6",
"version": "0.1.0",
"description": "Use tar to pack and unpack file",

@@ -10,3 +10,5 @@ "bin": {

"lint": "eslint src",
"prettify": "prettier --write src/**/*.js"
"prettify": "prettier --write src/**/*.js",
"test": "npm run lint && nyc ava",
"cover:report": "nyc report --reporter=text-lcov > coverage.lcov"
},

@@ -34,9 +36,16 @@ "repository": {

"devDependencies": {
"@ava/babel": "^1.0.1",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"eslint-config-wzx": "^0.1.2",
"ava": "^3.3.0",
"eslint-config-wzx": "^0.1.4",
"husky": "^4.2.1",
"lint-staged": "^10.0.7",
"prettier": "^1.19.1"
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"shelljs": "^0.8.3"
},
"ava": {
"babel": true
}
}
# tar-compress-cli
[![NPM version](https://img.shields.io/npm/v/tar-compress-cli.svg)](https://www.npmjs.com/package/tar-compress-cli)
[![NPM version](https://img.shields.io/npm/v/tar-compress-cli)](https://www.npmjs.com/package/tar-compress-cli)
[![Build Status](https://travis-ci.com/VicSolWang/tar-compress-cli.svg?branch=master)](https://travis-ci.com/VicSolWang/tar-compress-cli)
[![codecov](https://codecov.io/gh/VicSolWang/tar-compress-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/VicSolWang/tar-compress-cli)
[![NPM downloads](https://img.shields.io/npm/dt/tar-compress-cli)](https://www.npmjs.com/package/tar-compress-cli)

@@ -9,3 +12,3 @@ Use tar to pack and unpack file

npm install -g tar-compress-cli
npm install --save-dev tar-compress-cli

@@ -15,1 +18,31 @@ # Usage

tar-compress-cli <pack|unpack> [options]
## Pack Command options
-s, --source Set source file list [array] [required]
-t, --target Set target file [string] [default: "output.tgz"]
-v, --version Show version number
-h, --help Show help
### Example
tar-compress-cli pack -s source_1 source_2 -t target.tgz
## Unpack Command options
-s, --source Set source file [string] [required]
-e, --extractFile Set extract file list in the source file [array] [default: []]
-t, --target Set target file [string]
-v, --version Show version number
-h, --help Show help
### Example
tar-compress-cli unpack -s source.tgz -e extract_1 extract_2 -t target
# License
[MIT](LICENSE).

@@ -33,3 +33,3 @@ /**

.usage(`Usage: $0 ${command} [options]`)
.example(`$0 ${command} -s source -t target.tgz`)
.example(`$0 ${command} -s source_1 source_2 -t target.tgz`)
.help()

@@ -42,3 +42,3 @@ .alias('help', 'h'),

if (sourceFiles.length === 0) {
console.error('No such file or directory');
console.error('No such file or directory.');
process.exit(1);

@@ -49,3 +49,3 @@ } else {

if (err) {
console.error('Creat directory failed');
console.error('Creat directory failed.');
process.exit(1);

@@ -52,0 +52,0 @@ } else {

@@ -8,2 +8,3 @@ /**

const fs = require('fs-extra');
const path = require('path');
const tar = require('tar');

@@ -25,11 +26,18 @@

},
target: {
alias: 't',
describe: 'Set target file',
extractFile: {
alias: 'e',
describe: 'Set extract file list in the source file',
default: [],
type: 'array',
},
target: {
alias: 't',
describe: 'Set target directory',
type: 'string',
},
})
.usage(`Usage: $0 ${command} [options]`)
.example(`$0 ${command} -s source.tgz -t target`)
.example(
`$0 ${command} -s source.tgz -e extract_1 extract_2 -t target`,
)
.help()

@@ -40,11 +48,19 @@ .alias('help', 'h'),

if (!fs.pathExistsSync(sourceFile)) {
console.error('No such file or directory');
console.error('No such file or directory.');
process.exit(1);
} else {
const targetFiles = argv.target;
const extractFiles = argv.extractFile;
let targetDirectory;
if (!argv.target) {
targetDirectory = path.dirname(path.resolve(sourceFile));
} else {
fs.ensureDirSync(argv.target);
targetDirectory = path.resolve(argv.target);
}
tar.x(
{
file: sourceFile,
cwd: targetDirectory,
},
targetFiles,
extractFiles,
);

@@ -51,0 +67,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc