本文整理汇总了TypeScript中vs/base/common/path.normalize函数的典型用法代码示例。如果您正苦于以下问题:TypeScript normalize函数的具体用法?TypeScript normalize怎么用?TypeScript normalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normalize函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getPathLabel
export function getPathLabel(resource: URI | string, userHomeProvider?: IUserHomeProvider, rootProvider?: IWorkspaceFolderProvider): string {
if (typeof resource === 'string') {
resource = URI.file(resource);
}
// return early if we can resolve a relative path label from the root
if (rootProvider) {
const baseResource = rootProvider.getWorkspaceFolder(resource);
if (baseResource) {
const hasMultipleRoots = rootProvider.getWorkspace().folders.length > 1;
let pathLabel: string;
if (isEqual(baseResource.uri, resource)) {
pathLabel = ''; // no label if paths are identical
} else {
pathLabel = relativePath(baseResource.uri, resource)!;
}
if (hasMultipleRoots) {
const rootName = (baseResource && baseResource.name) ? baseResource.name : basename(baseResource.uri);
pathLabel = pathLabel ? (rootName + ' ⢠' + pathLabel) : rootName; // always show root basename if there are multiple
}
return pathLabel;
}
}
// return if the resource is neither file:// nor untitled:// and no baseResource was provided
if (resource.scheme !== Schemas.file && resource.scheme !== Schemas.untitled) {
return resource.with({ query: null, fragment: null }).toString(true);
}
// convert c:\something => C:\something
if (hasDriveLetter(resource.fsPath)) {
return normalize(normalizeDriveLetter(resource.fsPath));
}
// normalize and tildify (macOS, Linux only)
let res = normalize(resource.fsPath);
if (!isWindows && userHomeProvider) {
res = tildify(res, userHomeProvider.userHome);
}
return res;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:45,代码来源:labels.ts
示例2: builtinExtensionsPath
@memoize
get builtinExtensionsPath(): string {
const fromArgs = parsePathArg(this._args['builtin-extensions-dir'], process);
if (fromArgs) {
return fromArgs;
} else {
return path.normalize(path.join(getPathFromAmdModule(require, ''), '..', 'extensions'));
}
}
开发者ID:joelday,项目名称:vscode,代码行数:9,代码来源:environmentService.ts
示例3: extensionTestsLocationURI
@memoize
get extensionTestsLocationURI(): URI | undefined {
const s = this._args.extensionTestsPath;
if (s) {
if (/^[^:/?#]+?:\/\//.test(s)) {
return URI.parse(s);
}
return URI.file(path.normalize(s));
}
return undefined;
}
开发者ID:joelday,项目名称:vscode,代码行数:11,代码来源:environmentService.ts
示例4: assertMapping
export function assertMapping(writeFileIfDifferent: boolean, mapper: IKeyboardMapper, file: string): Promise<void> {
const filePath = path.normalize(getPathFromAmdModule(require, `vs/workbench/services/keybinding/test/${file}`));
return readFile(filePath).then((buff) => {
let expected = buff.toString();
const actual = mapper.dumpDebugInfo();
if (actual !== expected && writeFileIfDifferent) {
const destPath = filePath.replace(/vscode\/out\/vs/, 'vscode/src/vs');
writeFile(destPath, actual);
}
assert.deepEqual(actual.split(/\r\n|\n/), expected.split(/\r\n|\n/));
});
}
开发者ID:PKRoma,项目名称:vscode,代码行数:14,代码来源:keyboardMapperTestUtils.ts
示例5: parsePathArg
function parsePathArg(arg: string | undefined, process: NodeJS.Process): string | undefined {
if (!arg) {
return undefined;
}
// Determine if the arg is relative or absolute, if relative use the original CWD
// (VSCODE_CWD), not the potentially overridden one (process.cwd()).
const resolved = path.resolve(arg);
if (path.normalize(arg) === resolved) {
return resolved;
} else {
return path.resolve(process.env['VSCODE_CWD'] || process.cwd(), arg);
}
}
开发者ID:joelday,项目名称:vscode,代码行数:15,代码来源:environmentService.ts
示例6: isRootOrDriveLetter
export function isRootOrDriveLetter(path: string): boolean {
const pathNormalized = normalize(path);
if (isWindows) {
if (path.length > 3) {
return false;
}
return isWindowsDriveLetter(pathNormalized.charCodeAt(0))
&& pathNormalized.charCodeAt(1) === CharCode.Colon
&& (path.length === 2 || pathNormalized.charCodeAt(2) === CharCode.Backslash);
}
return pathNormalized === posix.sep;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:15,代码来源:extpath.ts
示例7: test
test('getFirstFrame', () => {
let stack = 'at vscode.commands.registerCommand (/Users/someone/Desktop/test-ts/out/src/extension.js:18:17)';
let frame = getFirstFrame(stack)!;
assert.equal(frame.uri.fsPath, normalize('/Users/someone/Desktop/test-ts/out/src/extension.js'));
assert.equal(frame.line, 18);
assert.equal(frame.column, 17);
stack = 'at /Users/someone/Desktop/test-ts/out/src/extension.js:18:17';
frame = getFirstFrame(stack)!;
assert.equal(frame.uri.fsPath, normalize('/Users/someone/Desktop/test-ts/out/src/extension.js'));
assert.equal(frame.line, 18);
assert.equal(frame.column, 17);
stack = 'at c:\\Users\\someone\\Desktop\\end-js\\extension.js:18:17';
frame = getFirstFrame(stack)!;
assert.equal(frame.uri.fsPath, 'c:\\Users\\someone\\Desktop\\end-js\\extension.js');
assert.equal(frame.line, 18);
assert.equal(frame.column, 17);
stack = 'at e.$executeContributedCommand(c:\\Users\\someone\\Desktop\\end-js\\extension.js:18:17)';
frame = getFirstFrame(stack)!;
assert.equal(frame.uri.fsPath, 'c:\\Users\\someone\\Desktop\\end-js\\extension.js');
assert.equal(frame.line, 18);
assert.equal(frame.column, 17);
stack = 'at /Users/someone/Desktop/test-ts/out/src/extension.js:18:17\nat /Users/someone/Desktop/test-ts/out/src/other.js:28:27\nat /Users/someone/Desktop/test-ts/out/src/more.js:38:37';
frame = getFirstFrame(stack)!;
assert.equal(frame.uri.fsPath, normalize('/Users/someone/Desktop/test-ts/out/src/extension.js'));
assert.equal(frame.line, 18);
assert.equal(frame.column, 17);
});
开发者ID:PKRoma,项目名称:vscode,代码行数:36,代码来源:console.test.ts
示例8: extensionDevelopmentLocationURI
@memoize
get extensionDevelopmentLocationURI(): URI[] | undefined {
const s = this._args.extensionDevelopmentPath;
if (Array.isArray(s)) {
return s.map(p => {
if (/^[^:/?#]+?:\/\//.test(p)) {
return URI.parse(p);
}
return URI.file(path.normalize(p));
});
} else if (s) {
if (/^[^:/?#]+?:\/\//.test(s)) {
return [URI.parse(s)];
}
return [URI.file(path.normalize(s))];
}
return undefined;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:18,代码来源:environmentService.ts
示例9: getEncodedDebugData
static getEncodedDebugData(modelUri: uri): { name: string, path: string, sessionId?: string, sourceReference?: number } {
let path: string;
let sourceReference: number | undefined;
let sessionId: string | undefined;
switch (modelUri.scheme) {
case Schemas.file:
path = normalize(modelUri.fsPath);
break;
case DEBUG_SCHEME:
path = modelUri.path;
if (modelUri.query) {
const keyvalues = modelUri.query.split('&');
for (let keyvalue of keyvalues) {
const pair = keyvalue.split('=');
if (pair.length === 2) {
switch (pair[0]) {
case 'session':
sessionId = decodeURIComponent(pair[1]);
break;
case 'ref':
sourceReference = parseInt(pair[1]);
break;
}
}
}
}
break;
default:
path = modelUri.toString();
break;
}
return {
name: resources.basenameOrAuthority(modelUri),
path,
sourceReference,
sessionId
};
}
开发者ID:eamodio,项目名称:vscode,代码行数:40,代码来源:debugSource.ts
示例10: test
test('Files: relative path matched once', function (done: () => void) {
this.timeout(testTimeout);
const engine = new FileSearchEngine({
type: QueryType.File,
folderQueries: ROOT_FOLDER_QUERY,
filePattern: path.normalize(path.join('examples', 'company.js'))
});
let count = 0;
let res: IRawFileMatch;
engine.search((result) => {
if (result) {
count++;
}
res = result;
}, () => { }, (error) => {
assert.ok(!error);
assert.equal(count, 1);
assert.equal(path.basename(res.relativePath), 'company.js');
done();
});
});
开发者ID:PKRoma,项目名称:vscode,代码行数:22,代码来源:search.test.ts
注:本文中的vs/base/common/path.normalize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论