-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract helper for checking if it's windows
- Loading branch information
Showing
3 changed files
with
36 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isWindows() { | ||
return process.platform === "win32"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,50 @@ | ||
import { join, normalize, resolve } from "path/posix"; | ||
import * as t from "tap"; | ||
import { isWindows } from "../helpers/isWindows"; | ||
import { isWrapped } from "../helpers/wrap"; | ||
import { Path } from "./Path"; | ||
import { createTestAgent } from "../helpers/createTestAgent"; | ||
|
||
t.test("it works", { skip: process.platform === "win32" }, async (t) => { | ||
const agent = createTestAgent(); | ||
t.test( | ||
"it works", | ||
{ skip: isWindows() ? "path is not the same as path/posix" : false }, | ||
async (t) => { | ||
const agent = createTestAgent(); | ||
|
||
agent.start([new Path()]); | ||
agent.start([new Path()]); | ||
|
||
const { join, resolve, normalize } = require("path/posix"); | ||
const { join, resolve, normalize } = require("path/posix"); | ||
|
||
// Path required after path/posix | ||
require("path"); | ||
// Path required after path/posix | ||
require("path"); | ||
|
||
const checkForDoubleWrapping = [join, resolve, normalize]; | ||
for (const fn of checkForDoubleWrapping) { | ||
if (isWrapped(fn) && isWrapped(fn.__original)) { | ||
t.fail(`${fn.name} is double wrapped!`); | ||
const checkForDoubleWrapping = [join, resolve, normalize]; | ||
for (const fn of checkForDoubleWrapping) { | ||
if (isWrapped(fn) && isWrapped(fn.__original)) { | ||
t.fail(`${fn.name} is double wrapped!`); | ||
} | ||
} | ||
} | ||
}); | ||
); | ||
|
||
t.test("it works", { skip: process.platform !== "win32" }, async (t) => { | ||
const agent = createTestAgent(); | ||
t.test( | ||
"it works", | ||
{ skip: !isWindows() ? "path is not the same as path/win32" : false }, | ||
async (t) => { | ||
const agent = createTestAgent(); | ||
|
||
agent.start([new Path()]); | ||
agent.start([new Path()]); | ||
|
||
const { join, resolve, normalize } = require("path/win32"); | ||
const { join, resolve, normalize } = require("path/win32"); | ||
|
||
// Path required after path/win32 | ||
require("path"); | ||
// Path required after path/win32 | ||
require("path"); | ||
|
||
const checkForDoubleWrapping = [join, resolve, normalize]; | ||
for (const fn of checkForDoubleWrapping) { | ||
if (isWrapped(fn) && isWrapped(fn.__original)) { | ||
t.fail(`${fn.name} is double wrapped!`); | ||
const checkForDoubleWrapping = [join, resolve, normalize]; | ||
for (const fn of checkForDoubleWrapping) { | ||
if (isWrapped(fn) && isWrapped(fn.__original)) { | ||
t.fail(`${fn.name} is double wrapped!`); | ||
} | ||
} | ||
} | ||
}); | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters