diff --git a/tgui/packages/common/collections.js b/tgui/packages/common/collections.js index 1e5c978942..b542967d47 100644 --- a/tgui/packages/common/collections.js +++ b/tgui/packages/common/collections.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + /** * Converts a given collection to an array. * diff --git a/tgui/packages/common/fp.js b/tgui/packages/common/fp.js index 4be45877e2..7aa00a00f3 100644 --- a/tgui/packages/common/fp.js +++ b/tgui/packages/common/fp.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + /** * Creates a function that returns the result of invoking the given * functions, where each successive invocation is supplied the return diff --git a/tgui/packages/common/logging.js b/tgui/packages/common/logging.js index 4ae1855fda..0dc222ae3d 100644 --- a/tgui/packages/common/logging.js +++ b/tgui/packages/common/logging.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + const inception = Date.now(); // Runtime detection diff --git a/tgui/packages/common/math.js b/tgui/packages/common/math.js index cc7a309563..c3013b5a32 100644 --- a/tgui/packages/common/math.js +++ b/tgui/packages/common/math.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + /** * Limits a number to the range between 'min' and 'max'. */ diff --git a/tgui/packages/common/react.js b/tgui/packages/common/react.js index 0828bb8864..dba84b7b10 100644 --- a/tgui/packages/common/react.js +++ b/tgui/packages/common/react.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + /** * Helper for conditionally adding/removing classes in React * diff --git a/tgui/packages/common/redux.js b/tgui/packages/common/redux.js index 257a9eebf5..7fb4432408 100644 --- a/tgui/packages/common/redux.js +++ b/tgui/packages/common/redux.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import { compose } from './fp'; /** diff --git a/tgui/packages/common/string.babel-plugin.cjs b/tgui/packages/common/string.babel-plugin.cjs index ba25e3f91d..68295aefcf 100644 --- a/tgui/packages/common/string.babel-plugin.cjs +++ b/tgui/packages/common/string.babel-plugin.cjs @@ -1,5 +1,7 @@ /** - * @file + * This plugin saves overall about 10KB on the final bundle size, so it's + * sort of worth it. + * * We are using a .cjs extension because: * * 1. Webpack CLI only supports CommonJS modules; @@ -9,8 +11,9 @@ * We need to copy-paste the whole "multiline" function because we can't * synchronously import an ES module from a CommonJS module. * - * This plugin saves overall about 10KB on the final bundle size, so it's - * sort of worth it. + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT */ /** diff --git a/tgui/packages/common/string.js b/tgui/packages/common/string.js index d05dbfb6fc..16a0921a25 100644 --- a/tgui/packages/common/string.js +++ b/tgui/packages/common/string.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + /** * Removes excess whitespace and indentation from the string. */ diff --git a/tgui/packages/common/timer.js b/tgui/packages/common/timer.js index e3feb69ca9..f4e26fa5aa 100644 --- a/tgui/packages/common/timer.js +++ b/tgui/packages/common/timer.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + /** * Returns a function, that, as long as it continues to be invoked, will * not be triggered. The function will be called after it stops being diff --git a/tgui/packages/common/vector.js b/tgui/packages/common/vector.js index fa98597896..1562df5991 100644 --- a/tgui/packages/common/vector.js +++ b/tgui/packages/common/vector.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import { map, reduce, zipWith } from './collections'; /** diff --git a/tgui/packages/tgui-dev-server/index.js b/tgui/packages/tgui-dev-server/index.js index 1e7683080c..f4e8155d29 100644 --- a/tgui/packages/tgui-dev-server/index.js +++ b/tgui/packages/tgui-dev-server/index.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import { setupWebpack, getWebpackConfig } from './webpack.js'; import { reloadByondCache } from './reloader.js'; diff --git a/tgui/packages/tgui-dev-server/link/client.js b/tgui/packages/tgui-dev-server/link/client.js index 774b7ed6db..af7a920c64 100644 --- a/tgui/packages/tgui-dev-server/link/client.js +++ b/tgui/packages/tgui-dev-server/link/client.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + let socket; const queue = []; const subscribers = []; diff --git a/tgui/packages/tgui-dev-server/link/retrace.js b/tgui/packages/tgui-dev-server/link/retrace.js index 74c87e6a55..e0b17a01d6 100644 --- a/tgui/packages/tgui-dev-server/link/retrace.js +++ b/tgui/packages/tgui-dev-server/link/retrace.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import { createLogger } from 'common/logging.js'; import fs from 'fs'; import { basename } from 'path'; diff --git a/tgui/packages/tgui-dev-server/link/server.js b/tgui/packages/tgui-dev-server/link/server.js index 84f3700048..94a79c9ad5 100644 --- a/tgui/packages/tgui-dev-server/link/server.js +++ b/tgui/packages/tgui-dev-server/link/server.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import { createLogger, directLog } from 'common/logging.js'; import http from 'http'; import { inspect } from 'util'; diff --git a/tgui/packages/tgui-dev-server/reloader.js b/tgui/packages/tgui-dev-server/reloader.js index 394e55afdb..e33f7226b9 100644 --- a/tgui/packages/tgui-dev-server/reloader.js +++ b/tgui/packages/tgui-dev-server/reloader.js @@ -1,9 +1,16 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import { createLogger } from 'common/logging.js'; import fs from 'fs'; import os from 'os'; import { basename } from 'path'; import { promisify } from 'util'; import { resolveGlob, resolvePath } from './util.js'; +import { regQuery } from './winreg.js'; const logger = createLogger('reloader'); @@ -40,6 +47,21 @@ export const findCacheRoot = async () => { return cacheRoot; } } + // Query the Windows Registry + if (process.platform === 'win32') { + logger.log('querying windows registry'); + let userpath = await regQuery( + 'HKCU\\Software\\Dantom\\BYOND', + 'userpath'); + if (userpath) { + cacheRoot = userpath + .replace(/\\$/, '') + .replace(/\\/g, '/') + + '/cache'; + logger.log(`found cache at '${cacheRoot}'`); + return cacheRoot; + } + } logger.log('found no cache directories'); }; diff --git a/tgui/packages/tgui-dev-server/util.js b/tgui/packages/tgui-dev-server/util.js index db34626721..50c0baad5a 100644 --- a/tgui/packages/tgui-dev-server/util.js +++ b/tgui/packages/tgui-dev-server/util.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import glob from 'glob'; import { resolve as resolvePath } from 'path'; import fs from 'fs'; diff --git a/tgui/packages/tgui-dev-server/webpack.js b/tgui/packages/tgui-dev-server/webpack.js index 778469a15b..c625827409 100644 --- a/tgui/packages/tgui-dev-server/webpack.js +++ b/tgui/packages/tgui-dev-server/webpack.js @@ -1,3 +1,9 @@ +/** + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + import { createLogger } from 'common/logging.js'; import fs from 'fs'; import { createRequire } from 'module'; diff --git a/tgui/packages/tgui-dev-server/winreg.js b/tgui/packages/tgui-dev-server/winreg.js new file mode 100644 index 0000000000..974135e76d --- /dev/null +++ b/tgui/packages/tgui-dev-server/winreg.js @@ -0,0 +1,47 @@ +/** + * Tools for dealing with Windows Registry bullshit. + * + * @file + * @copyright 2020 Aleksej Komarov + * @license MIT + */ + +import { exec } from 'child_process'; +import { createLogger } from 'common/logging.js'; +import { promisify } from 'util'; + +const logger = createLogger('winreg'); + +export const regQuery = async (path, key) => { + if (process.platform !== 'win32') { + return null; + } + try { + const command = `reg query "${path}" /v ${key}`; + const { stdout } = await promisify(exec)(command); + const keyPattern = ` ${key} `; + const indexOfKey = stdout.indexOf(keyPattern); + if (indexOfKey === -1) { + logger.error('could not find the registry key'); + return null; + } + const indexOfEol = stdout.indexOf('\r\n', indexOfKey); + if (indexOfEol === -1) { + logger.error('could not find the end of the line'); + return null; + } + const indexOfValue = stdout.indexOf( + ' ', + indexOfKey + keyPattern.length); + if (indexOfValue === -1) { + logger.error('could not find the start of the key value'); + return null; + } + const value = stdout.substring(indexOfValue + 4, indexOfEol); + return value; + } + catch (err) { + logger.error(err); + return null; + } +};