Skip to content

Commit

Permalink
Accommodate Node 10's fs.rmdir API with rimraf
Browse files Browse the repository at this point in the history
Also ensures cleanup of decompressed files/directories.

Removes Node 8 from the build matrix. The current version of ava is not
compatible with Node 8, and Node 8 is in general now at end-of-life.
  • Loading branch information
trptcolin committed Feb 27, 2020
1 parent 8850e7e commit 949027c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -3,4 +3,3 @@ language: node_js
node_js:
- '12'
- '10'
- '8'
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -45,6 +45,7 @@
"is-jpg": "^1.0.0",
"path-exists": "^3.0.0",
"pify": "^2.3.0",
"rimraf": "^3.0.2",
"xo": "*"
},
"ava": {
Expand Down
14 changes: 9 additions & 5 deletions test.js
Expand Up @@ -3,10 +3,19 @@ import path from 'path';
import isJpg from 'is-jpg';
import pathExists from 'path-exists';
import pify from 'pify';
import rimraf from 'rimraf';
import test from 'ava';
import m from '.';

const fsP = pify(fs);
const rimrafP = pify(rimraf);

test.after('ensure decompressed files and directories are cleaned up', async () => {
await rimrafP(path.join(__dirname, 'directory'));
await rimrafP(path.join(__dirname, 'dist'));
await rimrafP(path.join(__dirname, 'edge_case_dots'));
await rimrafP(path.join(__dirname, 'test.jpg'));
});

test('extract file', async t => {
const tarFiles = await m(path.join(__dirname, 'fixtures', 'file.tar'));
Expand Down Expand Up @@ -46,8 +55,6 @@ test.serial('extract file to directory', async t => {
t.is(files[0].path, 'test.jpg');
t.true(isJpg(files[0].data));
t.true(await pathExists(path.join(__dirname, 'test.jpg')));

await fsP.unlink(path.join(__dirname, 'test.jpg'));
});

test('extract symlink', async t => {
Expand All @@ -60,7 +67,6 @@ test('extract symlink', async t => {
test('extract directory', async t => {
await m(path.join(__dirname, 'fixtures', 'directory.tar'), __dirname);
t.true(await pathExists(path.join(__dirname, 'directory')));
await fsP.rmdir(path.join(__dirname, 'directory'));
});

test('strip option', async t => {
Expand Down Expand Up @@ -96,7 +102,6 @@ test.serial('set mtime', async t => {
const files = await m(path.join(__dirname, 'fixtures', 'file.tar'), __dirname);
const stat = await fsP.stat(path.join(__dirname, 'test.jpg'));
t.deepEqual(files[0].mtime, stat.mtime);
await fsP.unlink(path.join(__dirname, 'test.jpg'));
});

test('return emptpy array if no plugins are set', async t => {
Expand Down Expand Up @@ -133,5 +138,4 @@ test('allows filenames and directories to be written with dots in their names',
'edge_case_dots/x',
'edge_case_dots/sample../test.txt'
].sort());
await fsP.rmdir(path.join(__dirname, 'edge_case_dots'), {recursive: true});
});

0 comments on commit 949027c

Please sign in to comment.