delete old

This commit is contained in:
Zengtudor 2024-08-11 23:22:35 +08:00
parent 347a0758e0
commit e0d569cadc
3 changed files with 8 additions and 9 deletions

View File

@ -1,14 +1,13 @@
import { cloneDeep } from "lodash" import { cloneDeep } from "lodash"
import NmakeGlobal from "../interface/NmakeGlobal" import NmakeGlobal from "../interface/NmakeGlobal"
import printDebug from "../Tools/DebugPrint" import printDebug from "../Tools/DebugPrint"
import { popGlobalStack, pushGlobalStack } from "../Tools/GlobalStack"
const project = (name:string,callback:Function) =>{ const project = (name:string,callback:Function) =>{
const oldGlobal = (global as any).nmake as unknown as NmakeGlobal pushGlobalStack()
const nGlobal = cloneDeep(((global as any).nmake as unknown as NmakeGlobal));
(global as any).nmake = nGlobal
printDebug("adding project :"+name) printDebug("adding project :"+name)
callback() callback()
(global as any).nmake = oldGlobal popGlobalStack()
} }
export default project export default project

View File

@ -6,17 +6,19 @@ export const Global = global as any
let globalNmakeStacks = Global.globalStacks as NmakeGlobal[] let globalNmakeStacks = Global.globalStacks as NmakeGlobal[]
export const pushGlobalStack = () =>{ export const pushGlobalStack = () =>{
if(!Global.globalStacks){Global.globalStacks = [];globalNmakeStacks = Global.globalStacks as NmakeGlobal[]}
printDebug("pushing global stack") printDebug("pushing global stack")
if(!Global.globalStacks){Global.globalStacks = [];globalNmakeStacks = Global.globalStacks as NmakeGlobal[]}
globalNmakeStacks.push(Global.nmake) globalNmakeStacks.push(Global.nmake)
Global.nmake = cloneDeep(Global.nmake) Global.nmake = cloneDeep(Global.nmake)
} }
export const popGlobalStack = ()=>{ export const popGlobalStack = ()=>{
printDebug("popping global stack")
Global.nmake = globalNmakeStacks[globalNmakeStacks.length-1] Global.nmake = globalNmakeStacks[globalNmakeStacks.length-1]
globalNmakeStacks.pop() globalNmakeStacks.pop()
} }
export const getGlobalNmake=():NmakeGlobal=>{ export const getGlobalNmake=():NmakeGlobal=>{
printDebug("getting global nmake")
return Global.nmake return Global.nmake
} }

View File

@ -1,5 +1,3 @@
import {project} from "../../src/CliFunc/tools"; import CppProject from "../../src/Project/CppProject";
project("hello",()=>{ new CppProject("hello");
})