fix BigIntStats error on TypeScript

ignore Operator '&' cannot be applied to types 'number | bigint' and 'number'.
This commit is contained in:
filipenevola
2021-02-23 20:46:38 -04:00
parent 8b9296e2de
commit 5ed26e96b2
4 changed files with 14 additions and 8 deletions

View File

@@ -404,6 +404,8 @@ export function treeHash(root: string, optionsParams: {
}
hash.update('file ' + JSON.stringify(relativePath) + ' ' +
stat.size + ' ' + fileHash(absPath) + '\n');
// @ts-ignore
if (stat.mode & 0o100) {
hash.update('exec\n');
}
@@ -537,6 +539,8 @@ export function cp_r(from: string, to: string, options: {
// owner. (This mode will be modified by umask.) We don't copy the
// mode *directly* because this function is used by 'meteor create'
// which is copying from the read-only tools tree into a writable app.
// @ts-ignore
mode: (stat.mode & 0o100) ? 0o777 : 0o666,
});
@@ -1698,6 +1702,8 @@ export function copyFile(from: string, to: string, flags = 0) {
// modified by umask.) We don't copy the mode *directly* because this function
// is used by 'meteor create' which is copying from the read-only tools tree
// into a writable app.
// @ts-ignore
chmod(to, (stat.mode & 0o100) ? 0o777 : 0o666);
}
}

View File

@@ -1,4 +1,4 @@
import { FSWatcher, Stats } from "fs";
import { FSWatcher, Stats, BigIntStats } from "fs";
import { Profile } from "../tool-env/profile";
import {
statOrNull,
@@ -89,7 +89,7 @@ function acquireWatcher(absPath: string, callback: EntryCallback) {
}
function startNewWatcher(absPath: string): Entry {
let stat: Stats | null = null;
let stat: Stats | BigIntStats | null = null;
if (DEDUPLICATE_BY_INO) {
stat = statOrNull(absPath);

View File

@@ -1,4 +1,4 @@
import { Stats, FSWatcher, Dirent } from "fs";
import { Stats, BigIntStats, FSWatcher, Dirent } from "fs";
import * as files from "./files";
import * as safeWatcher from "./safe-watcher";
import { createHash } from "crypto";
@@ -351,7 +351,7 @@ function readAndStatDirectory(absPath: string) {
// Add slashes to the end of directories.
const contentsWithSlashes: string[] = [];
contents.forEach(entry => {
let stat: Dirent | Stats | null = entry;
let stat: Dirent | Stats | BigIntStats | null = entry;
let name = entry.name;
if (entry.isSymbolicLink()) {
@@ -428,7 +428,7 @@ export class Watcher {
watcher: safeWatcher.SafeWatcher | null;
// Undefined until we stat the file for the first time, then null
// if the file is observed to be missing.
lastStat?: Stats | null
lastStat?: Stats | BigIntStats | null
}> = Object.create(null);
constructor(options: {

View File

@@ -14,7 +14,7 @@ import {
convertToOSPath,
convertToPosixPath,
} from "../fs/files";
import { Stats } from "fs";
import { Stats, BigIntStats } from "fs";
import { wrap } from "optimism";
import {
optimisticStatOrNull,
@@ -42,7 +42,7 @@ export type ResolverOptions = {
}
export type Resolution = {
stat: Stats;
stat: Stats | BigIntStats;
path: string;
packageJsonMap?: Record<string, Record<string, any>>;
id?: string;
@@ -63,7 +63,7 @@ export default class Resolver {
private nodeModulesPaths: string[];
private mainFields: string[];
public statOrNull = optimisticStatOrNull as (path: string) => Stats | null;
public statOrNull = optimisticStatOrNull as (path: string) => Stats | BigIntStats | null;
constructor({
sourceRoot,