Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance tuning for getProjectFiles #612

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,20 @@ export async function getProjectFiles(rootDir: string = path.join('.', '/'), cal
let ignoredFilePaths: string[] = [];
ignoredFilePaths = ignoredFilePaths.concat(ignorePatterns);

// Replace OS specific path separator to common '/' char for console output
filePaths = filePaths.map((name) => name.replace(/\\/g, '/'));

// check ignore files
const ignoreMatches = multimatch(filePaths, ignorePatterns, { dot: true });
const intersection: string[] = filePaths.filter(file => !ignoreMatches.includes(file));

// Check if there are files that will conflict if renamed .gs to .js.
// When pushing to Apps Script, these files will overwrite each other.
filePaths.map((name: string) => {
intersection.map((name: string) => {
const fileNameWithoutExt = name.slice(0, -path.extname(name).length);
if (
filePaths.indexOf(fileNameWithoutExt + '.js') !== -1 &&
filePaths.indexOf(fileNameWithoutExt + '.gs') !== -1
intersection.indexOf(fileNameWithoutExt + '.js') !== -1 &&
intersection.indexOf(fileNameWithoutExt + '.gs') !== -1
) {
// Can't rename, conflicting files
abortPush = true;
Expand All @@ -107,13 +114,6 @@ export async function getProjectFiles(rootDir: string = path.join('.', '/'), cal
});
if (abortPush) return callback(new Error(), null, null);

// Replace OS specific path separator to common '/' char for console output
filePaths = filePaths.map((name) => name.replace(/\\/g, '/'));

// check ignore files
const ignoreMatches = multimatch(filePaths, ignorePatterns, { dot: true });
const intersection: string[] = filePaths.filter(file => !ignoreMatches.includes(file));

// Loop through files that are not ignored
let files = intersection
.map((name, i) => {
Expand Down