Skip to content

Commit

Permalink
fix: update std and eszip deps (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Mar 2, 2023
1 parent cceb293 commit 90a8a1d
Show file tree
Hide file tree
Showing 21 changed files with 600 additions and 342 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# Should match the `DENO_VERSION_RANGE` constant in `node/bridge.ts`.
deno-version: v1.22.0
- name: Setup Deno dependencies
run: deno cache https://deno.land/x/eszip@v0.28.0/eszip.ts
run: deno cache https://deno.land/x/eszip@v0.37.0/eszip.ts
- name: Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions deno/lib/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { load } from "https://deno.land/x/eszip@v0.28.0/loader.ts";
import { LoadResponse } from "https://deno.land/x/eszip@v0.28.0/mod.ts";
import * as path from "https://deno.land/std@0.127.0/path/mod.ts";
import { load } from "https://deno.land/x/eszip@v0.37.0/loader.ts";
import { LoadResponse } from "https://deno.land/x/eszip@v0.37.0/mod.ts";
import * as path from "https://deno.land/std@0.178.0/path/mod.ts";
import { retryAsync } from "https://deno.land/x/retry@v2.0.0/mod.ts";
import { isTooManyTries } from "https://deno.land/x/retry@v2.0.0/retry/tooManyTries.ts";

Expand Down
4 changes: 2 additions & 2 deletions deno/lib/stage2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { build, LoadResponse } from 'https://deno.land/x/eszip@v0.28.0/mod.ts'
import { build, LoadResponse } from 'https://deno.land/x/eszip@v0.37.0/mod.ts'

import * as path from 'https://deno.land/std@0.127.0/path/mod.ts'
import * as path from 'https://deno.land/std@0.178.0/path/mod.ts'

import type { InputFunction, WriteStage2Options } from '../../shared/stage2.ts'
import { importMapSpecifier, virtualRoot } from '../../shared/consts.ts'
Expand Down
15 changes: 0 additions & 15 deletions deno/vendor/deno.land/std@0.127.0/_util/assert.ts

This file was deleted.

25 changes: 25 additions & 0 deletions deno/vendor/deno.land/std@0.178.0/_util/asserts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

/**
* All internal non-test code, that is files that do not have `test` or `bench` in the name, must use the assertion functions within `_utils/asserts.ts` and not `testing/asserts.ts`. This is to create a separation of concerns between internal and testing assertions.
*/

export class DenoStdInternalError extends Error {
constructor(message: string) {
super(message);
this.name = "DenoStdInternalError";
}
}

/** Make an assertion, if not `true`, then throw. */
export function assert(expr: unknown, msg = ""): asserts expr {
if (!expr) {
throw new DenoStdInternalError(msg);
}
}

/** Use this to assert unreachable code. */
export function unreachable(): never {
throw new DenoStdInternalError("unreachable");
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

export type OSType = "windows" | "linux" | "darwin";
export type OSType = "windows" | "linux" | "darwin" | "freebsd";

export const osType: OSType = (() => {
// deno-lint-ignore no-explicit-any
Expand All @@ -12,11 +12,12 @@ export const osType: OSType = (() => {

// deno-lint-ignore no-explicit-any
const { navigator } = globalThis as any;
if (navigator?.appVersion?.includes?.("Win") ?? false) {
if (navigator?.appVersion?.includes?.("Win")) {
return "windows";
}

return "linux";
})();

export const isWindows = osType === "windows";
export const isLinux = osType === "linux";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
// This module is browser compatible.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Copyright the Browserify authors. MIT License.
// Ported from https://github.com/browserify/path-browserify/
// This module is browser compatible.
Expand All @@ -14,7 +14,7 @@ import {
CHAR_UPPERCASE_Z,
} from "./_constants.ts";

export function assertPath(path: string): void {
export function assertPath(path: string) {
if (typeof path !== "string") {
throw new TypeError(
`Path must be a string. Received ${JSON.stringify(path)}`,
Expand Down Expand Up @@ -113,6 +113,7 @@ export function _format(
const base: string = pathObject.base ||
(pathObject.name || "") + (pathObject.ext || "");
if (!dir) return base;
if (base === sep) return dir;
if (dir === pathObject.root) return dir + base;
return dir + sep + base;
}
Expand All @@ -131,3 +132,63 @@ export function encodeWhitespace(string: string): string {
return WHITESPACE_ENCODINGS[c] ?? c;
});
}

export function lastPathSegment(
path: string,
isSep: (char: number) => boolean,
start = 0,
): string {
let matchedNonSeparator = false;
let end = path.length;

for (let i = path.length - 1; i >= start; --i) {
if (isSep(path.charCodeAt(i))) {
if (matchedNonSeparator) {
start = i + 1;
break;
}
} else if (!matchedNonSeparator) {
matchedNonSeparator = true;
end = i + 1;
}
}

return path.slice(start, end);
}

export function stripTrailingSeparators(
segment: string,
isSep: (char: number) => boolean,
): string {
if (segment.length <= 1) {
return segment;
}

let end = segment.length;

for (let i = segment.length - 1; i > 0; i--) {
if (isSep(segment.charCodeAt(i))) {
end = i;
} else {
break;
}
}

return segment.slice(0, end);
}

export function stripSuffix(name: string, suffix: string): string {
if (suffix.length >= name.length) {
return name;
}

const lenDiff = name.length - suffix.length;

for (let i = suffix.length - 1; i >= 0; --i) {
if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
return name;
}
}

return name.slice(0, -suffix.length);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { SEP } from "./separator.ts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { isWindows, osType } from "../_util/os.ts";
Expand All @@ -12,14 +12,19 @@ const { join, normalize } = path;

export interface GlobOptions {
/** Extended glob syntax.
* See https://www.linuxjournal.com/content/bash-extended-globbing. Defaults
* to true. */
* See https://www.linuxjournal.com/content/bash-extended-globbing.
*
* @default {true}
*/
extended?: boolean;
/** Globstar syntax.
* See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
* If false, `**` is treated like `*`. Defaults to true. */
* If false, `**` is treated like `*`.
*
* @default {true}
*/
globstar?: boolean;
/** Whether globstar should be case insensitive. */
/** Whether globstar should be case-insensitive. */
caseInsensitive?: boolean;
/** Operating system. Defaults to the native OS. */
os?: OSType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Copyright the Browserify authors. MIT License.
// Ported mostly from https://github.com/browserify/path-browserify/
// This module is browser compatible.

/**
* Utilities for working with OS-specific file paths.
*
* Codes in the examples uses POSIX path but it automatically use Windows path
* on Windows. Use methods under `posix` or `win32` object instead to handle non
* platform specific path like:
* ```ts
* import { posix, win32 } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
* const p1 = posix.fromFileUrl("file:///home/foo");
* const p2 = win32.fromFileUrl("file:///home/foo");
* console.log(p1); // "/home/foo"
* console.log(p2); // "\\home\\foo"
* ```
*
* This module is browser compatible.
*
* @module
*/

import { isWindows } from "../_util/os.ts";
import * as _win32 from "./win32.ts";
Expand Down

0 comments on commit 90a8a1d

Please sign in to comment.