Skip to content

Commit deaeee8

Browse files
authored
build: remove custom types (#473)
1 parent a4b2ab4 commit deaeee8

File tree

6 files changed

+45
-12
lines changed

6 files changed

+45
-12
lines changed

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@
5252
"@types/minimatch": "^3.0.3",
5353
"@types/mocha": "^8.2.0",
5454
"@types/node": "^14.14.14",
55+
"@types/relateurl": "^0.2.28",
5556
"@types/semver": "^7.3.4",
57+
"@types/urlencode": "^1.1.2",
5658
"@types/xmldom": "^0.1.30",
5759
"chai": "^4.2.0",
5860
"chai-as-promised": "^7.1.1",
5961
"husky": "^4.3.6",
6062
"mocha": "^8.2.1",
6163
"nyc": "^15.1.0",
6264
"prettier": "2.2.1",
65+
"relateurl": "^0.2.7",
6366
"semantic-release": "^17.3.0",
6467
"semantic-release-vsce": "^3.0.1",
6568
"semver": "^7.3.4",

src/custom-typings/url-relative.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/custom-typings/urlencode.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/paths.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
import urlRelative = require('url-relative')
21
import fileUrl = require('file-url')
32
import * as url from 'url'
43
import * as path from 'path'
54
import { decode } from 'urlencode'
5+
import RelateUrl from 'relateurl'
6+
7+
/**
8+
* Options to make sure that RelateUrl only outputs relative URLs and performs not other "smart" modifications.
9+
* They would mess up things like prefix checking.
10+
*/
11+
const RELATE_URL_OPTIONS: RelateUrl.Options = {
12+
// Make sure RelateUrl does not prefer root-relative URLs if shorter
13+
output: RelateUrl.PATH_RELATIVE,
14+
// Make sure RelateUrl does not remove trailing slash if present
15+
removeRootTrailingSlash: false,
16+
// Make sure RelateUrl does not remove default ports
17+
defaultPorts: {},
18+
}
19+
20+
/**
21+
* Like `path.relative()` but for URLs.
22+
* Inverse of `url.resolve()` or `new URL(relative, base)`.
23+
*/
24+
const relativeUrl = (from: string, to: string): string => RelateUrl.relate(from, to, RELATE_URL_OPTIONS)
625

726
/** converts a server-side XDebug file URI to a local path for VS Code with respect to source root settings */
827
export function convertDebuggerPathToClient(
@@ -85,7 +104,7 @@ export function convertClientPathToDebugger(localPath: string, pathMapping?: { [
85104
serverSourceRootUrl += '/'
86105
}
87106
// get the part of the path that is relative to the source root
88-
const urlRelativeToSourceRoot = urlRelative(localSourceRootUrl, localFileUri)
107+
const urlRelativeToSourceRoot = relativeUrl(localSourceRootUrl, localFileUri)
89108
// resolve from the server source root
90109
serverFileUri = url.resolve(serverSourceRootUrl, urlRelativeToSourceRoot)
91110
} else {

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"exclude": ["node_modules", "out"],
2+
"include": ["src/**/*"],
33
"compilerOptions": {
44
"target": "es6",
55
"module": "commonjs",
@@ -13,6 +13,7 @@
1313
"strictNullChecks": true,
1414
"noImplicitReturns": true,
1515
"allowUnreachableCode": false,
16-
"noUnusedLocals": true
16+
"noUnusedLocals": true,
17+
"esModuleInterop": true
1718
}
1819
}

0 commit comments

Comments
 (0)