提交 0e519843 编写于 作者: J Johannes Rieken

use native path#{join,normalize} over our custom stuff

上级 d434d755
......@@ -7,7 +7,6 @@
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import * as extfs from 'vs/base/node/extfs';
import * as paths from 'vs/base/common/paths';
import { dirname, join } from 'path';
import { nfcall, Queue } from 'vs/base/common/async';
import * as fs from 'fs';
......@@ -159,7 +158,7 @@ function ensureWriteFileQueue(queueKey: string): Queue<void> {
*/
export function readDirsInDir(dirPath: string): TPromise<string[]> {
return readdir(dirPath).then(children => {
return TPromise.join(children.map(c => dirExists(paths.join(dirPath, c)))).then(exists => {
return TPromise.join(children.map(c => dirExists(join(dirPath, c)))).then(exists => {
return children.filter((_, i) => exists[i]);
});
});
......@@ -185,4 +184,4 @@ export function fileExists(path: string): TPromise<boolean> {
const tmpDir = os.tmpdir();
export function del(path: string, tmp = tmpDir): TPromise<void> {
return nfcall(extfs.del, path, tmp);
}
\ No newline at end of file
}
......@@ -6,12 +6,12 @@
import * as nls from 'vs/nls';
import * as dom from 'vs/base/browser/dom';
import * as types from 'vs/base/common/types';
import * as objects from 'vs/base/common/objects';
import Event, { Emitter } from 'vs/base/common/event';
import { join, normalize } from 'path';
import { TPromise } from 'vs/base/common/winjs.base';
import { onUnexpectedError } from 'vs/base/common/errors';
import * as paths from 'vs/base/common/paths';
import * as types from 'vs/base/common/types';
import Event, { Emitter } from 'vs/base/common/event';
import { ExtensionMessageCollector } from 'vs/platform/extensions/common/extensionsRegistry';
import { ITokenizationSupport, TokenizationRegistry, IState, LanguageId } from 'vs/editor/common/modes';
import { IModeService } from 'vs/editor/common/services/modeService';
......@@ -214,7 +214,7 @@ export class MainProcessTextMateSyntax implements ITextMateService {
return;
}
let normalizedAbsolutePath = paths.normalize(paths.join(extensionFolderPath, syntax.path));
let normalizedAbsolutePath = normalize(join(extensionFolderPath, syntax.path));
if (normalizedAbsolutePath.indexOf(extensionFolderPath) !== 0) {
collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", grammarsExtPoint.name, normalizedAbsolutePath, extensionFolderPath));
......
......@@ -7,7 +7,7 @@
import * as nls from 'vs/nls';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { valid } from 'semver';
import * as paths from 'vs/base/common/paths';
import { join } from 'path';
export interface IParsedVersion {
hasCaret: boolean;
......@@ -313,7 +313,7 @@ function baseIsValidExtensionDescription(extensionFolderPath: string, extensionD
notices.push(nls.localize('extensionDescription.main1', "property `{0}` can be omitted or must be of type `string`", 'main'));
return false;
} else {
let normalizedAbsolutePath = paths.normalize(paths.join(extensionFolderPath, extensionDescription.main));
let normalizedAbsolutePath = join(extensionFolderPath, extensionDescription.main);
if (normalizedAbsolutePath.indexOf(extensionFolderPath)) {
notices.push(nls.localize('extensionDescription.main2', "Expected `main` ({0}) to be included inside extension's folder ({1}). This might make the extension non-portable.", normalizedAbsolutePath, extensionFolderPath));
......@@ -340,4 +340,4 @@ export function isValidExtensionDescription(version: string, extensionFolderPath
}
return isValidExtensionVersion(version, extensionDescription, notices);
}
\ No newline at end of file
}
......@@ -5,7 +5,7 @@
'use strict';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as paths from 'vs/base/common/paths';
import { join } from 'path';
import { mkdirp, dirExists } from 'vs/base/node/pfs';
import Severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
......@@ -121,7 +121,7 @@ class ExtensionStoragePath {
value(extension: IExtensionDescription): string {
if (this._value) {
return paths.join(this._value, extension.id);
return join(this._value, extension.id);
}
return undefined;
}
......@@ -139,7 +139,7 @@ class ExtensionStoragePath {
.update(workspace.uid ? workspace.uid.toString() : '')
.digest('hex');
const storagePath = paths.join(this._environment.appSettingsHome, 'workspaceStorage', storageName);
const storagePath = join(this._environment.appSettingsHome, 'workspaceStorage', storageName);
return dirExists(storagePath).then(exists => {
if (exists) {
......@@ -276,7 +276,7 @@ export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExt
subscriptions: [],
get extensionPath() { return extensionDescription.extensionFolderPath; },
storagePath: this._storagePath.value(extensionDescription),
asAbsolutePath: (relativePath: string) => { return paths.normalize(paths.join(extensionDescription.extensionFolderPath, relativePath), true); }
asAbsolutePath: (relativePath: string) => { return join(extensionDescription.extensionFolderPath, relativePath); }
});
});
}
......
......@@ -7,7 +7,7 @@
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { onUnexpectedError } from 'vs/base/common/errors';
import { TPromise } from 'vs/base/common/winjs.base';
import { join } from 'vs/base/common/paths';
import { join } from 'path';
import { readdir, rimraf, stat } from 'vs/base/node/pfs';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
......@@ -57,7 +57,7 @@ export class NodeCachedDataManager {
// the editor starts. The strategy is to delete all files that are older than
// 3 months
const {nodeCachedDataDir} = this._environmentService;
const { nodeCachedDataDir } = this._environmentService;
if (!nodeCachedDataDir) {
return;
}
......
......@@ -8,7 +8,7 @@
import nls = require('vs/nls');
import pfs = require('vs/base/node/pfs');
import { TPromise } from 'vs/base/common/winjs.base';
import paths = require('vs/base/common/paths');
import { join } from 'path';
import { IRemoteCom } from 'vs/platform/extensions/common/ipcRemoteCom';
import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionService';
import { ExtHostThreadService } from 'vs/workbench/services/thread/common/extHostThreadService';
......@@ -124,7 +124,7 @@ export class ExtensionHostMain {
const fileNames = Object.keys(desiredFilesMap);
return TPromise.join(fileNames.map(f => pfs.exists(paths.join(folderPath, f)))).then(exists => {
return TPromise.join(fileNames.map(f => pfs.exists(join(folderPath, f)))).then(exists => {
fileNames
.filter((f, i) => exists[i])
.forEach(fileName => {
......
......@@ -12,7 +12,7 @@ import { IExtensionDescription, IMessage } from 'vs/platform/extensions/common/e
import Severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
import { groupBy, values } from 'vs/base/common/collections';
import paths = require('vs/base/common/paths');
import { join, normalize, extname } from 'path';
import json = require('vs/base/common/json');
import Types = require('vs/base/common/types');
import { isValidExtensionDescription } from 'vs/platform/extensions/node/extensionValidator';
......@@ -77,7 +77,7 @@ abstract class ExtensionManifestHandler {
this._collector = collector;
this._absoluteFolderPath = absoluteFolderPath;
this._isBuiltin = isBuiltin;
this._absoluteManifestPath = paths.join(absoluteFolderPath, MANIFEST_FILE);
this._absoluteManifestPath = join(absoluteFolderPath, MANIFEST_FILE);
}
}
......@@ -105,7 +105,7 @@ class ExtensionManifestParser extends ExtensionManifestHandler {
class ExtensionManifestNLSReplacer extends ExtensionManifestHandler {
public replaceNLS(extensionDescription: IExtensionDescription): TPromise<IExtensionDescription> {
let extension = paths.extname(this._absoluteManifestPath);
let extension = extname(this._absoluteManifestPath);
let basename = this._absoluteManifestPath.substr(0, this._absoluteManifestPath.length - extension.length);
return pfs.fileExists(basename + '.nls' + extension).then(exists => {
......@@ -241,7 +241,7 @@ class ExtensionManifestValidator extends ExtensionManifestHandler {
// main := absolutePath(`main`)
if (extensionDescription.main) {
extensionDescription.main = paths.normalize(paths.join(this._absoluteFolderPath, extensionDescription.main));
extensionDescription.main = join(this._absoluteFolderPath, extensionDescription.main);
}
extensionDescription.extensionFolderPath = this._absoluteFolderPath;
......@@ -261,7 +261,7 @@ export class ExtensionScanner {
absoluteFolderPath: string,
isBuiltin: boolean
): TPromise<IExtensionDescription> {
absoluteFolderPath = paths.normalize(absoluteFolderPath);
absoluteFolderPath = normalize(absoluteFolderPath);
let parser = new ExtensionManifestParser(version, collector, absoluteFolderPath, isBuiltin);
return parser.parse().then((extensionDescription) => {
......@@ -293,7 +293,7 @@ export class ExtensionScanner {
let obsolete = TPromise.as({});
if (!isBuiltin) {
obsolete = pfs.readFile(paths.join(absoluteFolderPath, '.obsolete'), 'utf8')
obsolete = pfs.readFile(join(absoluteFolderPath, '.obsolete'), 'utf8')
.then(raw => JSON.parse(raw))
.then(null, err => ({}));
}
......@@ -314,7 +314,7 @@ export class ExtensionScanner {
return;
}
const {id, version} = getIdAndVersionFromLocalExtensionId(folder);
const { id, version } = getIdAndVersionFromLocalExtensionId(folder);
if (!id || !version) {
nonGallery.push(folder);
......@@ -330,7 +330,7 @@ export class ExtensionScanner {
return [...nonGallery, ...latest];
})
.then(folders => TPromise.join(folders.map(f => this.scanExtension(version, collector, paths.join(absoluteFolderPath, f), isBuiltin))))
.then(folders => TPromise.join(folders.map(f => this.scanExtension(version, collector, join(absoluteFolderPath, f), isBuiltin))))
.then(extensionDescriptions => extensionDescriptions.filter(item => item !== null))
.then(null, err => {
collector.error(absoluteFolderPath, err);
......@@ -349,7 +349,7 @@ export class ExtensionScanner {
absoluteFolderPath: string,
isBuiltin: boolean
): TPromise<IExtensionDescription[]> {
return pfs.fileExists(paths.join(absoluteFolderPath, MANIFEST_FILE)).then((exists) => {
return pfs.fileExists(join(absoluteFolderPath, MANIFEST_FILE)).then((exists) => {
if (exists) {
return this.scanExtension(version, collector, absoluteFolderPath, isBuiltin).then((extensionDescription) => {
if (extensionDescription === null) {
......@@ -364,4 +364,4 @@ export class ExtensionScanner {
return [];
});
}
}
\ No newline at end of file
}
......@@ -7,7 +7,7 @@
import * as nls from 'vs/nls';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { parse } from 'vs/base/common/json';
import * as paths from 'vs/base/common/paths';
import { join } from 'path';
import { TPromise } from 'vs/base/common/winjs.base';
import { readFile } from 'vs/base/node/pfs';
import { ExtensionMessageCollector, ExtensionsRegistry } from 'vs/platform/extensions/common/extensionsRegistry';
......@@ -70,7 +70,7 @@ export class MainProcessTextMateSnippet implements IWorkbenchContribution {
collector.error(nls.localize('invalid.path.0', "Expected string in `contributes.{0}.path`. Provided value: {1}", snippetsExtensionPoint.name, String(snippet.path)));
return;
}
let normalizedAbsolutePath = paths.normalize(paths.join(extensionFolderPath, snippet.path));
let normalizedAbsolutePath = join(extensionFolderPath, snippet.path);
if (normalizedAbsolutePath.indexOf(extensionFolderPath) !== 0) {
collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", snippetsExtensionPoint.name, normalizedAbsolutePath, extensionFolderPath));
......
......@@ -10,7 +10,7 @@ import 'vs/workbench/parts/snippets/electron-browser/tabCompletion';
import nls = require('vs/nls');
import winjs = require('vs/base/common/winjs.base');
import paths = require('vs/base/common/paths');
import { join } from 'path';
import actions = require('vs/base/common/actions');
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import platform = require('vs/platform/platform');
......@@ -63,7 +63,7 @@ class OpenSnippetsAction extends actions.Action {
return this.quickOpenService.pick(picks, { placeHolder: nls.localize('openSnippet.pickLanguage', "Select Language for Snippet") }).then((language) => {
if (language) {
var snippetPath = paths.join(this.environmentService.appSettingsHome, 'snippets', language.id + '.json');
var snippetPath = join(this.environmentService.appSettingsHome, 'snippets', language.id + '.json');
return fileExists(snippetPath).then((success) => {
if (success) {
return this.openFile(snippetPath);
......
......@@ -6,7 +6,7 @@
'use strict';
import workbenchExt = require('vs/workbench/common/contributions');
import paths = require('vs/base/common/paths');
import { join } from 'path';
import async = require('vs/base/common/async');
import winjs = require('vs/base/common/winjs.base');
import { mkdirp, fileExists, readdir } from 'vs/base/node/pfs';
......@@ -35,7 +35,7 @@ export class SnippetsTracker implements workbenchExt.IWorkbenchContribution {
@IEnvironmentService environmentService: IEnvironmentService,
@IExtensionService extensionService: IExtensionService
) {
this.snippetFolder = paths.join(environmentService.appSettingsHome, 'snippets');
this.snippetFolder = join(environmentService.appSettingsHome, 'snippets');
this.toDispose = [];
this.fileWatchDelayer = new async.ThrottledDelayer<void>(SnippetsTracker.FILE_WATCH_DELAY);
......@@ -73,7 +73,7 @@ export class SnippetsTracker implements workbenchExt.IWorkbenchContribution {
return readFilesInDir(this.snippetFolder, /\.json$/).then(snippetFiles => {
return winjs.TPromise.join(snippetFiles.map(snippetFile => {
var modeId = snippetFile.replace(/\.json$/, '').toLowerCase();
var snippetPath = paths.join(this.snippetFolder, snippetFile);
var snippetPath = join(this.snippetFolder, snippetFile);
let languageIdentifier = this.modeService.getLanguageIdentifier(modeId);
if (languageIdentifier) {
return readAndRegisterSnippets(this.snippetService, languageIdentifier, snippetPath);
......@@ -107,7 +107,7 @@ function readFilesInDir(dirPath: string, namePattern: RegExp = null): winjs.TPro
if (namePattern && !namePattern.test(child)) {
return winjs.TPromise.as(null);
}
return fileExists(paths.join(dirPath, child)).then(isFile => {
return fileExists(join(dirPath, child)).then(isFile => {
return isFile ? child : null;
});
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册