mirror of
https://github.com/smogon/sprites.git
synced 2026-04-25 07:18:19 -05:00
ts tupctime
This commit is contained in:
parent
ad51a0464b
commit
dca677d52d
|
|
@ -50,13 +50,36 @@ importers:
|
||||||
typescript: ^3.9.7
|
typescript: ^3.9.7
|
||||||
tools/tupctime:
|
tools/tupctime:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@types/better-sqlite3': 5.4.0
|
||||||
|
'@types/debug': 4.1.5
|
||||||
|
'@types/node': 14.0.23
|
||||||
better-sqlite3: 7.0.1
|
better-sqlite3: 7.0.1
|
||||||
debug: 4.1.1
|
debug: 4.1.1
|
||||||
|
devDependencies:
|
||||||
|
typescript: 3.9.7
|
||||||
specifiers:
|
specifiers:
|
||||||
|
'@types/better-sqlite3': ^5.4.0
|
||||||
|
'@types/debug': ^4.1.5
|
||||||
|
'@types/node': ^14.0.23
|
||||||
better-sqlite3: ^7.0.1
|
better-sqlite3: ^7.0.1
|
||||||
debug: ^4.1.1
|
debug: ^4.1.1
|
||||||
|
typescript: ^3.9.7
|
||||||
lockfileVersion: 5.1
|
lockfileVersion: 5.1
|
||||||
packages:
|
packages:
|
||||||
|
/@types/better-sqlite3/5.4.0:
|
||||||
|
dependencies:
|
||||||
|
'@types/integer': 1.0.1
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-nzm7lJ7l3jBmGUbtkL8cdOMhPkN6Pw2IM+b0V7iIKba+YKiLrjkIy7vVLsBIVnd7+lgzBzrHsXZxCaFTcmw5Ow==
|
||||||
|
/@types/debug/4.1.5:
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==
|
||||||
|
/@types/integer/1.0.1:
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-DmZDpSVnsuBrOhtHwE1oKmUJ3qVjHhhNQ7WnZy9/RhH3A24Ar+9o4SoaCWcTzQhalpRDIAMsfdoZLWNJtdBR7A==
|
||||||
/@types/node/14.0.23:
|
/@types/node/14.0.23:
|
||||||
dev: false
|
dev: false
|
||||||
resolution:
|
resolution:
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ AND name NOT IN ('^', '$')`);
|
||||||
const updateQuery = db.prepare(`UPDATE node SET mtime = ? WHERE id = ?`);
|
const updateQuery = db.prepare(`UPDATE node SET mtime = ? WHERE id = ?`);
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
const stack = [{isDir: true, id: 0, path: "."}];
|
const stack : {isDir: boolean, id : number, path: string, ctime?: bigint, name?: string}[] = [{isDir: true, id: 0, path: "."}];
|
||||||
|
|
||||||
let item;
|
let item;
|
||||||
while (item = stack.pop()) {
|
while (item = stack.pop()) {
|
||||||
|
|
@ -57,11 +57,16 @@ function update() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// bigint calculation is necessary to avoid rounding errors/spurious update
|
// bigint calculation is necessary to avoid rounding errors/spurious update
|
||||||
|
//
|
||||||
|
// typescript doesn't understand second argument to lstatSync, or
|
||||||
|
// that division can work between a number and bigint, so ignore
|
||||||
|
//
|
||||||
|
// @ts-ignore
|
||||||
const ctime = fs.lstatSync(item.path, {bigint: true}).ctimeMs / 1000n;
|
const ctime = fs.lstatSync(item.path, {bigint: true}).ctimeMs / 1000n;
|
||||||
if (ctime !== item.ctime) {
|
if (ctime !== item.ctime) {
|
||||||
debug(`Updating ${item.path}: ${ctime}, ${item.ctime}`);
|
debug(`Updating ${item.path}: ${ctime}, ${item.ctime}`);
|
||||||
if (updateQuery.run(ctime, item.id).changes !== 1)
|
if (updateQuery.run(ctime, item.id).changes !== 1)
|
||||||
throw new Error(`Couldn't update ${path}`);
|
throw new Error(`Couldn't update ${item.path}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,17 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"better-sqlite3":"^7.0.1",
|
"@types/better-sqlite3": "^5.4.0",
|
||||||
"debug":"^4.1.1"
|
"@types/debug": "^4.1.5",
|
||||||
|
"@types/node": "^14.0.23",
|
||||||
|
"better-sqlite3": "^7.0.1",
|
||||||
|
"debug": "^4.1.1"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "tsc"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "^3.9.7"
|
||||||
|
},
|
||||||
|
"main": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
tools/tupctime/tsconfig.json
Normal file
6
tools/tupctime/tsconfig.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"extends": "../../tsconfig-base",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "dist",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"target": "es2018",
|
"target": "es2020",
|
||||||
"lib": ["es2018"],
|
"lib": ["es2020"],
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user