Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
biqing.hu committed Apr 2, 2022
2 parents c73cb9e + 784d477 commit 2f93ba5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"lint": "tslint ./src/**/*.ts --fix"
},
"dependencies": {
"7zip-min": "^1.4.1",
"axios": "^0.21.1",
"bluebird": "^3.5.4",
"cli-color": "^1.4.0",
Expand Down
39 changes: 39 additions & 0 deletions src/commands/7zip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as zCompresser from '7zip-min'
import { _, packageHelper, exit, exec, getCurrentBranchName, consoleColor, cwd, io } from '../lib'

/**
* 忽略node_modules与.git对当前工程压缩成一个zip包放置在dist文件夹下
*/
export default {
/**
* 启动
*/
async start({ file }) {
const filePath = `${file}`.endsWith('.7z') ? `${file}` : `${file}.7z`
const newFilePath = io.pathTool.isAbsolute(filePath) ? filePath : io.pathTool.resolve(cwd, filePath)
const destDir = newFilePath.replace(/\.7z$/, '')

io.empty(destDir)
consoleColor.yellow(`文件路径:${newFilePath}`)
consoleColor.yellow(`压解到:${destDir}...`)

await new Promise((resolve, reject) => {
zCompresser.unpack(newFilePath, destDir, err => {
if (err) {
reject(err)
} else {
resolve(true)
}
})
}
)
consoleColor.green(`解压完成,文件夹:${destDir}`, true)
},
command: [
'<file>',
'对.7z文件进行解压缩',
{

}
]
}
3 changes: 3 additions & 0 deletions src/lib/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const io = {
fs,
home,
pathTool,
empty(dir) {
return fs.emptyDirSync(dir)
},
ensureDir(dir) {
return fs.ensureDir(dir)
},
Expand Down

0 comments on commit 2f93ba5

Please sign in to comment.