Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Extension/.eslintignore

This file was deleted.

155 changes: 0 additions & 155 deletions Extension/.eslintrc.js

This file was deleted.

13 changes: 8 additions & 5 deletions Extension/.scripts/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,28 @@ export async function main() {
}

export async function all() {
await rimraf(...(await getModifiedIgnoredFiles()).filter(each => !each.includes('node_modules')));
await rimraf(...(await getModifiedIgnoredFiles()).filter((each): each is string => each !== undefined && !each.includes('node_modules')));
Comment thread
sean-mcmanus marked this conversation as resolved.
}

export async function reset() {
verbose(`Resetting all .gitignored files in extension`);
await rimraf(...await getModifiedIgnoredFiles());
await rimraf(...(await getModifiedIgnoredFiles()).filter((each): each is string => each !== undefined));
}

async function details(files: string[]) {
let all = await Promise.all(files.filter(each => each).map(async (each) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [filename, stats ] = await filepath.stats(each);
const [filename, stats] = await filepath.stats(each);
if (!stats) {
return null;
}
return {
filename: stats.isDirectory() ? cyan(`${each}${sep}**`) : brightGreen(`${each}`),
date: stats.mtime.toLocaleDateString().replace(/\b(\d)\//g, '0$1\/'),
time: stats.mtime.toLocaleTimeString().replace(/^(\d)\:/g, '0$1:'),
modified: stats.mtime
};
}));
})).then(results => results.filter((each): each is NonNullable<typeof each> => each !== null));
Comment thread
sean-mcmanus marked this conversation as resolved.
Outdated
all = all.sort((a, b) => a.modified.getTime() - b.modified.getTime());
// print a formatted table so the date and time are aligned
const max = all.reduce((max, each) => Math.max(max, each.filename.length), 0);
Expand All @@ -56,7 +59,7 @@ export async function show(opt?: string) {
case 'ignored':
case 'untracked':
console.log(cyan('\n\nUntracked+Ignored files:'));
return details(await getModifiedIgnoredFiles());
return details((await getModifiedIgnoredFiles()).filter((each): each is string => each !== undefined));

default:
return error(`Unknown option '${opt}'`);
Expand Down
10 changes: 7 additions & 3 deletions Extension/.scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ export async function getModifiedIgnoredFiles() {
}

// return the full path of files that would be removed.
// eslint-disable-next-line @typescript-eslint/no-misused-promises
return Promise.all(stdio.filter("Would remove").map((s) => filepath.exists(s.replace(/^Would remove /, ''), $root)).filter(p => p));
Comment thread
sean-mcmanus marked this conversation as resolved.
}

export async function rimraf(...paths: string[]) {
const all = [];
const all: Promise<void>[] = [];
for (const each of paths) {
if (!each) {
continue;
Expand All @@ -82,6 +83,9 @@ export async function mkdir(filePath: string) {
}
throw new Error(`Cannot create directory '${filePath}' because there is a file there.`);
}
if (!fullPath) {
throw new Error(`Cannot create directory '${filePath}' because the path is invalid.`);
}

await md(fullPath, { recursive: true });
return fullPath;
Expand Down Expand Up @@ -258,7 +262,7 @@ export function position(text: string) {
return gray(`${text}`);
}

export async function assertAnyFolder(oneOrMoreFolders: string | string[], errorMessage?: string): Promise<string> {
export async function assertAnyFolder(oneOrMoreFolders: string | string[], errorMessage?: string): Promise<string | undefined> {
Comment thread
sean-mcmanus marked this conversation as resolved.
Comment thread
sean-mcmanus marked this conversation as resolved.
oneOrMoreFolders = is.array(oneOrMoreFolders) ? oneOrMoreFolders : [oneOrMoreFolders];
for (const each of oneOrMoreFolders) {
const result = await filepath.isFolder(each, $root);
Expand All @@ -275,7 +279,7 @@ export async function assertAnyFolder(oneOrMoreFolders: string | string[], error
}
}

export async function assertAnyFile(oneOrMoreFiles: string | string[], errorMessage?: string): Promise<string> {
export async function assertAnyFile(oneOrMoreFiles: string | string[], errorMessage?: string): Promise<string | undefined> {
Comment thread
sean-mcmanus marked this conversation as resolved.
Comment thread
sean-mcmanus marked this conversation as resolved.
oneOrMoreFiles = is.array(oneOrMoreFiles) ? oneOrMoreFiles : [oneOrMoreFiles];
for (const each of oneOrMoreFiles) {
const result = await filepath.isFile(each, $root);
Expand Down
2 changes: 1 addition & 1 deletion Extension/.scripts/copyWalkthruMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function watch() {
verbose(`Watching ${source} folder for changes.`);
console.log('Press Ctrl+C to exit.');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for await (const event of watchFiles(source, {recursive: true })) {
for await (const event of watchFiles(source, { recursive: true })) {
await main();
}
}
Expand Down
2 changes: 0 additions & 2 deletions Extension/.scripts/generateOptionsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */

/* eslint-disable no-prototype-builtins */

import { resolve } from 'path';
import { $root, read, write } from './common';

Expand Down
3 changes: 2 additions & 1 deletion Extension/.scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"esModuleInterop": true
"esModuleInterop": true,
"strictNullChecks": true
}
}
Loading
Loading