archive.js 976 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { test } from 'ava';
  2. import { removeAsync } from 'fs-extra-promise';
  3. import { extract, extractTarGz, compress } from '../dist/lib/archive';
  4. import { tmpName, tmpFile, tmpDir } from '../dist/lib/util';
  5. (process.env.CI ? test.skip : test)('extract', async (t) => {
  6. const { path, cleanup } = await tmpDir();
  7. await extract('./caches/nwjs-v0.14.7-osx-x64.zip', path);
  8. cleanup();
  9. });
  10. (process.env.CI ? test.skip : test)('extractTarGz', async (t) => {
  11. const { path, cleanup } = await tmpDir();
  12. await extractTarGz('./caches/nwjs-v0.14.7-linux-x64.tar.gz', path);
  13. cleanup();
  14. });
  15. (process.env.CI ? test.skip : test)('compress', async (t) => {
  16. // Don't use `tmpFile`, which keeps the file open and results in exceptions when spawning.
  17. const path = await tmpName();
  18. const code = await compress('./assets/', [ './project/index.html', './project/package.json' ], 'zip', path);
  19. t.is(code, 0);
  20. await removeAsync(path);
  21. });