From d3dacd21b041a02baf902a0f16cbf1a0811b3bc1 Mon Sep 17 00:00:00 2001 From: mycroftjr Date: Sun, 1 Oct 2023 12:32:47 -0700 Subject: [PATCH] windows compatibility changes --- package.json | 9 +++++---- scripts/extract-simdata-types.ts | 17 ++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index ec976224..82f699c9 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,15 @@ }, "main": "./models.js", "scripts": { - "clean": "rm -rf ./dst/**", - "dev": "npm run clean ; tsc --watch", + "clean": "rm -rf ./dst/** || true", + "dev": "npm run clean && tsc --watch", "dev:serve": "npm run build && ts-node \"./server/app.ts\"", - "build": "npm run clean ; tsc ; node scripts/prepublish.cjs", + "build": "npm run clean && tsc && node scripts/prepublish.cjs", "publish": "npm run build && sh scripts/publish.sh", "test": "mocha -r ts-node/register \"test/**/*.test.ts\"", "test:coverage": "nyc mocha -r ts-node/register \"test/**/*.test.ts\"", - "test:current": "mocha -r ts-node/register \"test/**/combined-tuning-resource.test.ts\"" + "test:current": "mocha -r ts-node/register \"test/**/combined-tuning-resource.test.ts\"", + "extractsimdata": "npm run build && ts-node \"./scripts/extract-simdata-types.ts\"" }, "author": "frankkulak", "funding": { diff --git a/scripts/extract-simdata-types.ts b/scripts/extract-simdata-types.ts index 5e7bb67f..205db6bd 100644 --- a/scripts/extract-simdata-types.ts +++ b/scripts/extract-simdata-types.ts @@ -1,5 +1,6 @@ import fs from "fs"; import glob from "glob"; +import path from "path"; import { Package, SimDataResource } from "../dst/models"; import { BinaryResourceType, SimDataGroup, TuningResourceType } from "../dst/enums"; import { ResourceKeyPair } from "../dst/lib/packages/types"; @@ -8,6 +9,7 @@ import { formatAsHexString } from "@s4tk/hashing/formatting" const directories = [ '/Applications/The Sims 4 Packs', '/Applications/The Sims 4.app', + 'C:/Program Files/EA Games/The Sims 4', ]; const groupsToIgnore = new Set([ @@ -25,11 +27,11 @@ const groupsToIgnore = new Set([ function findPackagePaths(): Promise { return new Promise(resolve => { - const packagePaths = []; + const packagePaths: string[] = []; directories.forEach(directory => { const files = glob.sync(directory + '/**/*.package'); - packagePaths.push(...files); + packagePaths.push(...files.filter((p) => !path.basename(p).startsWith("Strings_"))); }); resolve(packagePaths); @@ -48,13 +50,10 @@ findPackagePaths().then(packagePaths => { const entries = Package.extractResources(buffer, { resourceFilter(type, group, inst) { - if (type === BinaryResourceType.SimData) { - if (groupsToIgnore.has(group)) return false; - if (group in SimDataGroup) return false; - return true; - } else { - return false; - } + if (type !== BinaryResourceType.SimData) return false; + if (groupsToIgnore.has(group)) return false; + if (group in SimDataGroup) return false; + return true; } });