cool, now i **have** to fix the master branch. ree

This commit is contained in:
Letter N
2020-07-21 13:39:28 +08:00
parent e27bc2eda3
commit cf51c5aa2a
18 changed files with 165 additions and 3 deletions
+6
View File
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { setupWebpack, getWebpackConfig } from './webpack.js';
import { reloadByondCache } from './reloader.js';
@@ -1,3 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
let socket;
const queue = [];
const subscribers = [];
@@ -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';
@@ -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';
+22
View File
@@ -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');
};
+6
View File
@@ -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';
+6
View File
@@ -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';
+47
View File
@@ -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;
}
};