mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-29 21:18:06 +08:00
octokit client should follow proxy settings (#314)
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
import * as io from '../../io/src/io'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import {MatchKind} from '../src/internal-match-kind'
|
||||
import {promises as fs} from 'fs'
|
||||
|
||||
// Mock 'os' before importing Pattern
|
||||
/* eslint-disable import/first */
|
||||
/* eslint-disable @typescript-eslint/promise-function-async */
|
||||
// Note, @typescript-eslint/promise-function-async is a false positive due to the
|
||||
// mock factory delegate which returns any. Fixed in a future version of jest.
|
||||
jest.mock('os', () => jest.requireActual('os'))
|
||||
const os = jest.requireMock('os')
|
||||
import {Pattern} from '../src/internal-pattern'
|
||||
jest.resetModuleRegistry()
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
@@ -32,19 +24,13 @@ describe('pattern', () => {
|
||||
})
|
||||
|
||||
it('escapes homedir', async () => {
|
||||
const originalHomedir = os.homedir
|
||||
const home = path.join(getTestTemp(), 'home-with-[and]')
|
||||
await fs.mkdir(home, {recursive: true})
|
||||
try {
|
||||
os.homedir = () => home
|
||||
const pattern = new Pattern('~/m*')
|
||||
const pattern = new Pattern('~/m*', undefined, home)
|
||||
|
||||
expect(pattern.searchPath).toBe(home)
|
||||
expect(pattern.match(path.join(home, 'match'))).toBeTruthy()
|
||||
expect(pattern.match(path.join(home, 'not-match'))).toBeFalsy()
|
||||
} finally {
|
||||
os.homedir = originalHomedir
|
||||
}
|
||||
expect(pattern.searchPath).toBe(home)
|
||||
expect(pattern.match(path.join(home, 'match'))).toBeTruthy()
|
||||
expect(pattern.match(path.join(home, 'not-match'))).toBeFalsy()
|
||||
})
|
||||
|
||||
it('escapes root', async () => {
|
||||
|
||||
5
packages/glob/package-lock.json
generated
5
packages/glob/package-lock.json
generated
@@ -4,11 +4,6 @@
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.1.tgz",
|
||||
"integrity": "sha512-xD+CQd9p4lU7ZfRqmUcbJpqR+Ss51rJRVeXMyOLrZQImN9/8Sy/BEUBnHO/UKD3z03R686PVTLfEPmkropGuLw=="
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as assert from 'assert'
|
||||
import * as path from 'path'
|
||||
import assert from 'assert'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as assert from 'assert'
|
||||
import * as path from 'path'
|
||||
import * as pathHelper from './internal-path-helper'
|
||||
import assert from 'assert'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as assert from 'assert'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import * as pathHelper from './internal-path-helper'
|
||||
import assert from 'assert'
|
||||
import {Minimatch, IMinimatch, IOptions as IMinimatchOptions} from 'minimatch'
|
||||
import {MatchKind} from './internal-match-kind'
|
||||
import {Path} from './internal-path'
|
||||
@@ -48,8 +48,13 @@ export class Pattern {
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/291
|
||||
|
||||
constructor(pattern: string)
|
||||
constructor(pattern: string, segments: undefined, homedir: string)
|
||||
constructor(negate: boolean, segments: string[])
|
||||
constructor(patternOrNegate: string | boolean, segments?: string[]) {
|
||||
constructor(
|
||||
patternOrNegate: string | boolean,
|
||||
segments?: string[],
|
||||
homedir?: string
|
||||
) {
|
||||
// Pattern overload
|
||||
let pattern: string
|
||||
if (typeof patternOrNegate === 'string') {
|
||||
@@ -78,7 +83,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
// Normalize slashes and ensures absolute root
|
||||
pattern = Pattern.fixupPattern(pattern)
|
||||
pattern = Pattern.fixupPattern(pattern, homedir)
|
||||
|
||||
// Segments
|
||||
this.segments = new Path(pattern).segments
|
||||
@@ -177,7 +182,7 @@ export class Pattern {
|
||||
/**
|
||||
* Normalizes slashes and ensures absolute root
|
||||
*/
|
||||
private static fixupPattern(pattern: string): string {
|
||||
private static fixupPattern(pattern: string, homedir?: string): string {
|
||||
// Empty
|
||||
assert(pattern, 'pattern cannot be empty')
|
||||
|
||||
@@ -206,7 +211,7 @@ export class Pattern {
|
||||
}
|
||||
// Replace leading `~` segment
|
||||
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) {
|
||||
const homedir = os.homedir()
|
||||
homedir = homedir || os.homedir()
|
||||
assert(homedir, 'Unable to determine HOME directory')
|
||||
assert(
|
||||
pathHelper.hasAbsoluteRoot(homedir),
|
||||
|
||||
Reference in New Issue
Block a user