本文整理汇总了TypeScript中vs/base/common/paths.dirname函数的典型用法代码示例。如果您正苦于以下问题:TypeScript dirname函数的具体用法?TypeScript dirname怎么用?TypeScript dirname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dirname函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: dirname
export function dirname(resource: URI): URI | null {
if (resource.scheme === Schemas.file) {
return URI.file(paths.dirname(fsPath(resource)));
}
let dirname = paths.dirname(resource.path, '/');
if (resource.authority && dirname.length && dirname.charCodeAt(0) !== CharCode.Slash) {
return null; // If a URI contains an authority component, then the path component must either be empty or begin with a CharCode.Slash ("/") character
}
return resource.with({
path: dirname
});
}
开发者ID:felipecaputo,项目名称:vscode,代码行数:12,代码来源:resources.ts
示例2: resolve
resolve(variable: Variable): string {
const { name } = variable;
if (name === 'TM_FILENAME') {
return basename(this._model.uri.fsPath);
} else if (name === 'TM_FILENAME_BASE') {
const name = basename(this._model.uri.fsPath);
const idx = name.lastIndexOf('.');
if (idx <= 0) {
return name;
} else {
return name.slice(0, idx);
}
} else if (name === 'TM_DIRECTORY') {
const dir = dirname(this._model.uri.fsPath);
return dir !== '.' ? dir : '';
} else if (name === 'TM_FILEPATH') {
return this._model.uri.fsPath;
}
return undefined;
}
开发者ID:servicesgpr,项目名称:vscode,代码行数:26,代码来源:snippetVariables.ts
示例3: resolve
resolve(name: string): string {
if (name === 'SELECTION' || name === 'TM_SELECTED_TEXT') {
return this._model.getValueInRange(this._selection);
} else if (name === 'TM_CURRENT_LINE') {
return this._model.getLineContent(this._selection.positionLineNumber);
} else if (name === 'TM_CURRENT_WORD') {
const info = this._model.getWordAtPosition({
lineNumber: this._selection.positionLineNumber,
column: this._selection.positionColumn
});
return info ? info.word : '';
} else if (name === 'TM_LINE_INDEX') {
return String(this._selection.positionLineNumber - 1);
} else if (name === 'TM_LINE_NUMBER') {
return String(this._selection.positionLineNumber);
} else if (name === 'TM_FILENAME') {
return basename(this._model.uri.fsPath);
} else if (name === 'TM_DIRECTORY') {
const dir = dirname(this._model.uri.fsPath);
return dir !== '.' ? dir : '';
} else if (name === 'TM_FILEPATH') {
return this._model.uri.fsPath;
} else {
return undefined;
}
}
开发者ID:hungys,项目名称:vscode,代码行数:34,代码来源:snippetVariables.ts
示例4: assertDirname
function assertDirname(path: string, expected: string, win = false) {
const actual = paths.dirname(path, win ? '\\' : '/');
if (actual !== expected) {
assert.fail(`${path}: expected: ${expected}, ours: ${actual}`);
}
}
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:7,代码来源:paths.test.ts
示例5: save
export function save(file: string, content: string): any {
mkdirp(dirname(file)).then(() => {
return writeFile(file, content, 'ascii');
}, err => {
//
});
}
开发者ID:AjuanM,项目名称:vscode,代码行数:7,代码来源:fileAccessor.ts
示例6: createPath
export function createPath(parent: string, fileName: string): string {
var stat = fs.statSync(parent);
if (stat && !stat.isDirectory()) {
parent = dirname(parent);
}
return join(parent, fileName);
};
开发者ID:AjuanM,项目名称:vscode,代码行数:8,代码来源:fileAccessor.ts
示例7: defaultWorkspacePath
export function defaultWorkspacePath(contextService: IWorkspaceContextService, historyService: IHistoryService, environmentService: IEnvironmentService): string {
// Check for current workspace config file first...
if (contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && !isUntitledWorkspace(contextService.getWorkspace().configuration.fsPath, environmentService)) {
return dirname(contextService.getWorkspace().configuration.fsPath);
}
// ...then fallback to default folder path
return defaultFolderPath(contextService, historyService);
}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:10,代码来源:workspaceCommands.ts
示例8: dirname
export function dirname(resource: uri): uri {
const dirname = paths.dirname(resource.path);
if (resource.authority && dirname && !paths.isAbsolute(dirname)) {
return null; // If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character
}
return resource.with({
path: dirname
});
}
开发者ID:jinlongchen2018,项目名称:vscode,代码行数:10,代码来源:resources.ts
示例9: defaultFilePath
export function defaultFilePath(contextService: IWorkspaceContextService, historyService: IHistoryService): string {
let candidate: URI;
// Check for last active file first...
candidate = historyService.getLastActiveFile();
// ...then for last active file root
if (!candidate) {
candidate = historyService.getLastActiveWorkspaceRoot('file');
}
return candidate ? dirname(candidate.fsPath) : void 0;
}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:13,代码来源:workspaceCommands.ts
示例10:
handler: (accessor) => {
const historyService = accessor.get(IHistoryService);
const terminalService = accessor.get(ITerminalService);
const root = historyService.getLastActiveWorkspaceRoot(Schemas.file);
if (root) {
terminalService.openTerminal(root.fsPath);
} else {
// Opens current file's folder, if no folder is open in editor
const activeFile = historyService.getLastActiveFile();
if (activeFile) {
terminalService.openTerminal(paths.dirname(activeFile.fsPath));
}
}
}
开发者ID:liunian,项目名称:vscode,代码行数:14,代码来源:execution.contribution.ts
注:本文中的vs/base/common/paths.dirname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论