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 NmakeGlobal from "../interface/NmakeGlobal"
import printDebug from "../Tools/DebugPrint"
import { popGlobalStack, pushGlobalStack } from "../Tools/GlobalStack"
const project = (name:string,callback:Function) =>{
const oldGlobal = (global as any).nmake as unknown as NmakeGlobal
const nGlobal = cloneDeep(((global as any).nmake as unknown as NmakeGlobal));
(global as any).nmake = nGlobal
pushGlobalStack()
printDebug("adding project :"+name)
callback()
(global as any).nmake = oldGlobal
popGlobalStack()
}
export default project

View File

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