octokit client should follow proxy settings (#314)
This commit is contained in:
1 parent
2742d5f50a
commit
bb53d60349
5 files changed
+17
-31
No files matched your search
@@ -1,17 +1,9 @@
|
|||||||
import * as io from '../../io/src/io'
|
import * as io from '../../io/src/io'
|
||||||
|
import * as os from 'os'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {MatchKind} from '../src/internal-match-kind'
|
import {MatchKind} from '../src/internal-match-kind'
|
||||||
import {promises as fs} from 'fs'
|
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'
|
import {Pattern} from '../src/internal-pattern'
|
||||||
jest.resetModuleRegistry()
|
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
@@ -32,19 +24,13 @@ describe('pattern', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('escapes homedir', async () => {
|
it('escapes homedir', async () => {
|
||||||
const originalHomedir = os.homedir
|
|
||||||
const home = path.join(getTestTemp(), 'home-with-[and]')
|
const home = path.join(getTestTemp(), 'home-with-[and]')
|
||||||
await fs.mkdir(home, {recursive: true})
|
await fs.mkdir(home, {recursive: true})
|
||||||
try {
|
const pattern = new Pattern('~/m*', undefined, home)
|
||||||
os.homedir = () => home
|
|
||||||
const pattern = new Pattern('~/m*')
|
|
||||||
|
|
||||||
expect(pattern.searchPath).toBe(home)
|
expect(pattern.searchPath).toBe(home)
|
||||||
expect(pattern.match(path.join(home, 'match'))).toBeTruthy()
|
expect(pattern.match(path.join(home, 'match'))).toBeTruthy()
|
||||||
expect(pattern.match(path.join(home, 'not-match'))).toBeFalsy()
|
expect(pattern.match(path.join(home, 'not-match'))).toBeFalsy()
|
||||||
} finally {
|
|
||||||
os.homedir = originalHomedir
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('escapes root', async () => {
|
it('escapes root', async () => {
|
||||||
|
|||||||
Generated
-5
@@ -4,11 +4,6 @@
|
|||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"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": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
"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 * as path from 'path'
|
||||||
|
import assert from 'assert'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as assert from 'assert'
|
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as pathHelper from './internal-path-helper'
|
import * as pathHelper from './internal-path-helper'
|
||||||
|
import assert from 'assert'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -1,7 +1,7 @@
|
|||||||
import * as assert from 'assert'
|
|
||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as pathHelper from './internal-path-helper'
|
import * as pathHelper from './internal-path-helper'
|
||||||
|
import assert from 'assert'
|
||||||
import {Minimatch, IMinimatch, IOptions as IMinimatchOptions} from 'minimatch'
|
import {Minimatch, IMinimatch, IOptions as IMinimatchOptions} from 'minimatch'
|
||||||
import {MatchKind} from './internal-match-kind'
|
import {MatchKind} from './internal-match-kind'
|
||||||
import {Path} from './internal-path'
|
import {Path} from './internal-path'
|
||||||
@@ -48,8 +48,13 @@ export class Pattern {
|
|||||||
// https://github.com/typescript-eslint/typescript-eslint/issues/291
|
// https://github.com/typescript-eslint/typescript-eslint/issues/291
|
||||||
|
|
||||||
constructor(pattern: string)
|
constructor(pattern: string)
|
||||||
|
constructor(pattern: string, segments: undefined, homedir: string)
|
||||||
constructor(negate: boolean, segments: string[])
|
constructor(negate: boolean, segments: string[])
|
||||||
constructor(patternOrNegate: string | boolean, segments?: string[]) {
|
constructor(
|
||||||
|
patternOrNegate: string | boolean,
|
||||||
|
segments?: string[],
|
||||||
|
homedir?: string
|
||||||
|
) {
|
||||||
// Pattern overload
|
// Pattern overload
|
||||||
let pattern: string
|
let pattern: string
|
||||||
if (typeof patternOrNegate === 'string') {
|
if (typeof patternOrNegate === 'string') {
|
||||||
@@ -78,7 +83,7 @@ export class Pattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalize slashes and ensures absolute root
|
// Normalize slashes and ensures absolute root
|
||||||
pattern = Pattern.fixupPattern(pattern)
|
pattern = Pattern.fixupPattern(pattern, homedir)
|
||||||
|
|
||||||
// Segments
|
// Segments
|
||||||
this.segments = new Path(pattern).segments
|
this.segments = new Path(pattern).segments
|
||||||
@@ -177,7 +182,7 @@ export class Pattern {
|
|||||||
/**
|
/**
|
||||||
* Normalizes slashes and ensures absolute root
|
* Normalizes slashes and ensures absolute root
|
||||||
*/
|
*/
|
||||||
private static fixupPattern(pattern: string): string {
|
private static fixupPattern(pattern: string, homedir?: string): string {
|
||||||
// Empty
|
// Empty
|
||||||
assert(pattern, 'pattern cannot be empty')
|
assert(pattern, 'pattern cannot be empty')
|
||||||
|
|
||||||
@@ -206,7 +211,7 @@ export class Pattern {
|
|||||||
}
|
}
|
||||||
// Replace leading `~` segment
|
// Replace leading `~` segment
|
||||||
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) {
|
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) {
|
||||||
const homedir = os.homedir()
|
homedir = homedir || os.homedir()
|
||||||
assert(homedir, 'Unable to determine HOME directory')
|
assert(homedir, 'Unable to determine HOME directory')
|
||||||
assert(
|
assert(
|
||||||
pathHelper.hasAbsoluteRoot(homedir),
|
pathHelper.hasAbsoluteRoot(homedir),
|
||||||
|
|||||||
Reference in new issue
Block a user