mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-05 16:38:32 +00:00
Make tab width 2 spaces (#445)
This commit is contained in:
@@ -4,36 +4,34 @@ import { Create } from './create-api';
|
||||
import { toPosixPath, parentPosix, posix } from './create-paths';
|
||||
|
||||
export namespace CreateUri {
|
||||
export const scheme = 'arduino-create';
|
||||
export const root = toUri(posix.sep);
|
||||
export const scheme = 'arduino-create';
|
||||
export const root = toUri(posix.sep);
|
||||
|
||||
export function toUri(posixPathOrResource: string | Create.Resource): URI {
|
||||
const posixPath =
|
||||
typeof posixPathOrResource === 'string'
|
||||
? posixPathOrResource
|
||||
: toPosixPath(posixPathOrResource.path);
|
||||
return new URI(
|
||||
Uri.parse(posixPath).with({ scheme, authority: 'create' })
|
||||
);
|
||||
}
|
||||
export function toUri(posixPathOrResource: string | Create.Resource): URI {
|
||||
const posixPath =
|
||||
typeof posixPathOrResource === 'string'
|
||||
? posixPathOrResource
|
||||
: toPosixPath(posixPathOrResource.path);
|
||||
return new URI(Uri.parse(posixPath).with({ scheme, authority: 'create' }));
|
||||
}
|
||||
|
||||
export function is(uri: URI): boolean {
|
||||
return uri.scheme === scheme;
|
||||
}
|
||||
export function is(uri: URI): boolean {
|
||||
return uri.scheme === scheme;
|
||||
}
|
||||
|
||||
export function equals(left: URI, right: URI): boolean {
|
||||
return is(left) && is(right) && left.toString() === right.toString();
|
||||
}
|
||||
export function equals(left: URI, right: URI): boolean {
|
||||
return is(left) && is(right) && left.toString() === right.toString();
|
||||
}
|
||||
|
||||
export function parent(uri: URI): URI {
|
||||
if (!is(uri)) {
|
||||
throw new Error(
|
||||
`Invalid URI scheme. Expected '${scheme}' got '${uri.scheme}' instead.`
|
||||
);
|
||||
}
|
||||
if (equals(uri, root)) {
|
||||
return uri;
|
||||
}
|
||||
return toUri(parentPosix(uri.path.toString()));
|
||||
export function parent(uri: URI): URI {
|
||||
if (!is(uri)) {
|
||||
throw new Error(
|
||||
`Invalid URI scheme. Expected '${scheme}' got '${uri.scheme}' instead.`
|
||||
);
|
||||
}
|
||||
if (equals(uri, root)) {
|
||||
return uri;
|
||||
}
|
||||
return toUri(parentPosix(uri.path.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user