feat: add puzzle clear template runtime
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
existsSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
statSync,
|
||||
watch,
|
||||
writeFileSync,
|
||||
@@ -1684,6 +1685,26 @@ function normalizePath(path) {
|
||||
return path.replace(/\\/gu, '/');
|
||||
}
|
||||
|
||||
function safeRealpath(pathValue) {
|
||||
try {
|
||||
return realpathSync(pathValue);
|
||||
} catch {
|
||||
return resolve(pathValue);
|
||||
}
|
||||
}
|
||||
|
||||
function isDirectModuleExecution(argv1, moduleUrl, resolvePath = safeRealpath) {
|
||||
if (!argv1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return resolvePath(argv1) === resolvePath(fileURLToPath(moduleUrl));
|
||||
} catch {
|
||||
return resolve(argv1) === fileURLToPath(moduleUrl);
|
||||
}
|
||||
}
|
||||
|
||||
function buildSpacetimePublishArgs({database, server, preserveDatabase}) {
|
||||
const args = [
|
||||
'publish',
|
||||
@@ -1735,6 +1756,7 @@ export {
|
||||
createDevServerSpawnOptions,
|
||||
createWatchConfigs,
|
||||
isSpacetimePublishPermissionError,
|
||||
isDirectModuleExecution,
|
||||
parseSpacetimeToolVersion,
|
||||
parseArgs,
|
||||
shouldAcceptWatchEvent,
|
||||
@@ -1765,6 +1787,6 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
if (isDirectModuleExecution(process.argv[1], import.meta.url)) {
|
||||
void main();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user