使用柏树解压缩文件

发布于 2025-01-23 05:06:02 字数 924 浏览 1 评论 0原文

我需要使用'解压缩'解压缩文件,而我正在使用以下代码进行相同的操作,但是它部分解剖了,但是它会抛出无效的路径错误(因为路径包含特殊字符 *)请帮助我对其进行修复

let path = 'cypress/downloads/'
let file = '910-00001.1-20220419-1843.zip'

describe('example unzip', () => {
  it(' test', () => {
    cy.task('unzipping', { path, file })
    })





//task code (Added it into plugins --> index.js)

const unzipping = require('./unzipping')

module.exports = (on, config) => {
    on('task', {
        'unzipping': unzipping.unzip,
    })
}

// ./unzipping文件(创建一个名为unzipping.js的文件中的插件文件夹)

const decompress = require('decompress');

const unzip = ({ path, file }) => decompress(path + file, path + 'unzip/' + file.replace('.zip', ''))

module.exports = {
    unzip,
}

enter image description hereI need to unzip the file using 'unzipping' whereas I am using the below code to do the same but it is partially unzipping but it is throwing an Invalid path error (as path contains special character *).please help me to fix it

let path = 'cypress/downloads/'
let file = '910-00001.1-20220419-1843.zip'

describe('example unzip', () => {
  it(' test', () => {
    cy.task('unzipping', { path, file })
    })





//task code (Added it into plugins --> index.js)

const unzipping = require('./unzipping')

module.exports = (on, config) => {
    on('task', {
        'unzipping': unzipping.unzip,
    })
}

// ./unzipping file (created a file named unzipping.js inside plugin folder)

const decompress = require('decompress');

const unzip = ({ path, file }) => decompress(path + file, path + 'unzip/' + file.replace('.zip', ''))

module.exports = {
    unzip,
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘和柠 2025-01-30 05:06:02

因此,我尝试了您上面提供的所有代码,并且效果很好。

我唯一能想到的是邮政编码的内容是问题。在我的测试中,我用两个文本文件1.txt2.txt进行了一个简单的邮政编码,然后运行测试,在文件夹/cypress/下载/UNZIP/910-00001.1-20220419-1843

我建议您使用虚拟邮政编码执行同样的操作,如果代码工作起作用,请查看910-00001.1-20220419-1843.zip的内容。

So, I tried all your code you gave above, and it worked perfectly.

The only thing I can think if is the contents of the zip is the problem. In my test I made a simple zip with two text files 1.txt and 2.txt, then running the test, found them in the folder /cypress/downloads/unzip/910-00001.1-20220419-1843.

I suggest you do the same with a dummy zip, if the code works then look at the contents of 910-00001.1-20220419-1843.zip.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文