Skip to content

Commit 9db60b6

Browse files
authored
fix(windows): handle paths correctly (#64)
1 parent 92077dc commit 9db60b6

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- '8'
3+
- '14'
44
git:
55
submodules: false
66
before_script:

lib/wrappers/file-system.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import * as fs from "fs";
22
import * as path from "path";
33
import * as yauzl from "yauzl";
4-
import * as util from "util";
54
import * as shelljs from "shelljs";
65

7-
const access = util.promisify(fs.access);
8-
const mkdir = util.promisify(fs.mkdir);
9-
106
export class FileSystem {
117
public exists(filePath: string): boolean {
128
return fs.existsSync(path.resolve(filePath));
@@ -66,12 +62,5 @@ export class FileSystem {
6662
}
6763

6864
function createParentDirsIfNeeded(filePath: string) {
69-
const dirs = path.dirname(filePath).split(path.sep);
70-
return dirs.reduce((p, dir) => p.then(parent => {
71-
const current = `${parent}${path.sep}${dir}`;
72-
73-
return access(current)
74-
.catch(e => mkdir(current))
75-
.then(() => current);
76-
}), Promise.resolve(''));
65+
return fs.promises.mkdir(path.dirname(filePath), {recursive: true});
7766
}

test/wrappers/file-system.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('FileSystem', () => {
1818
].join('');
1919
const tmpDir = `${tmpdir()}/${datetime}`;
2020
const testFilePath = `${__dirname}/example.zip`;
21-
const filesThatNeedToExtsit = [
21+
const filesThatNeedToExist = [
2222
`${tmpDir}/test/android-local-build-requirements.ts`,
2323
`${tmpDir}/test/android-tools-info.ts`,
2424
`${tmpDir}/test/ios-local-build-requirements.ts`,
@@ -27,11 +27,11 @@ describe('FileSystem', () => {
2727
];
2828

2929
it('should extract in example zip archive in tmp folder', done => {
30-
const fs = new FileSystem();
30+
const fs = new FileSystem();
3131

3232
fs.extractZip(testFilePath, tmpDir)
3333
.then(() => {
34-
const allExists = filesThatNeedToExtsit
34+
const allExists = filesThatNeedToExist
3535
.map(fs.exists)
3636
.reduce((acc, r) => acc && r, true);
3737

0 commit comments

Comments
 (0)