proper argument typings. devMode ON
parent
5ca6f94e04
commit
562bc94f9b
3
.system
3
.system
|
|
@ -55,5 +55,6 @@
|
|||
"SLOT3": "0F0B6AEB69754319A7E480E3989F7E54",
|
||||
"SLOT4": "34064741B6324D9BBCEE0A1364F21220",
|
||||
"SLOT5": "18461538E5A1487EBC9F54040295440A"
|
||||
}
|
||||
},
|
||||
"devMode": true
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
import { system } from '@kernel:base';
|
||||
import { system, ParsedSystemState } from '@kernel:base';
|
||||
import { resolve } from 'path';
|
||||
import { writeFileSync } from 'fs';
|
||||
|
||||
export default function save() {
|
||||
const timeStart = new Date().getTime();
|
||||
const obj: any = {
|
||||
const obj: ParsedSystemState = {
|
||||
handoff: system.handoff,
|
||||
instances: {},
|
||||
aliases: {}
|
||||
aliases: {},
|
||||
devMode: system.devMode
|
||||
};
|
||||
for(const [id, info] of system.instances.entries()) {
|
||||
obj.instances[id] = {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ declare module "@kernel:base" {
|
|||
type Id = string;
|
||||
type ParsedSystemState = {
|
||||
handoff: string,
|
||||
devMode: boolean,
|
||||
instances: {
|
||||
[id: Id]: {
|
||||
config: any,
|
||||
|
|
@ -31,6 +32,7 @@ declare module "@kernel:base" {
|
|||
aliases: Map<string, string>;
|
||||
instances: Map<string, Instance>;
|
||||
handoff: string;
|
||||
devMode: boolean;
|
||||
}
|
||||
const system: System;
|
||||
}
|
||||
|
|
|
|||
34
src/index.ts
34
src/index.ts
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path="./externals.d.ts" />
|
||||
|
||||
import { Instance, ParsedSystemState } from '@kernel:base';
|
||||
import { Instance, ParsedSystemState, System } from '@kernel:base';
|
||||
import '@kernel:log-hook';
|
||||
import createExecutor from '@commands:executor';
|
||||
import create from '@commands:create';
|
||||
|
|
@ -17,12 +17,11 @@ import md5 from 'md5';
|
|||
const args = process.argv.slice(2);
|
||||
const [ startupFile ] = args;
|
||||
|
||||
export type Id = string;
|
||||
|
||||
export const system = {
|
||||
export const system: System = {
|
||||
instances: new Map<string, Instance>(),
|
||||
handoff: '',
|
||||
aliases: new Map<string, string>()
|
||||
aliases: new Map<string, string>(),
|
||||
devMode: false
|
||||
}
|
||||
|
||||
export function reverseAliasMap() {
|
||||
|
|
@ -47,7 +46,22 @@ export function autoColorString(string: string) {
|
|||
|
||||
export const exec = async (s: string, echo = true) => {
|
||||
if(echo) console.log(chalk.cyan('@ ') + chalk.ansi256(242)(s));
|
||||
await executor(...(s.split(' ')));
|
||||
|
||||
const args: (string | number | boolean)[] = [];
|
||||
for(const arg of s.split(' ')) {
|
||||
const asNum = parseFloat(arg);
|
||||
const isTrue = arg.toLowerCase() === 'true';
|
||||
const isBoolean = isTrue || arg.toLowerCase() === 'false';
|
||||
if(isBoolean) {
|
||||
args.push(isTrue);
|
||||
} else if(!isNaN(asNum)) {
|
||||
args.push(asNum)
|
||||
} else {
|
||||
args.push(arg);
|
||||
}
|
||||
}
|
||||
|
||||
await executor(...args);
|
||||
};
|
||||
|
||||
export const kernel = {
|
||||
|
|
@ -87,8 +101,12 @@ export const kernel = {
|
|||
await exec(line);
|
||||
}
|
||||
},
|
||||
set(variable: string, ...rest: string[]) {
|
||||
(system as any)[variable] = rest.join(' ');
|
||||
set(variable: string, ...rest: any) {
|
||||
if(rest.length > 1) {
|
||||
(system as any)[variable] = rest.join(' ');
|
||||
} else {
|
||||
(system as any)[variable] = rest[0];
|
||||
}
|
||||
},
|
||||
help: help
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ function randomNormal(width: number = 1, offset: number = 0) {
|
|||
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
|
||||
while(v === 0) v = Math.random();
|
||||
const base = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
|
||||
return offset + base * width;
|
||||
}
|
||||
|
||||
export function pull() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue