-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from ch1ny/fix/build-main
fix: 修复主进程编译函数&主进程监听
- Loading branch information
Showing
5 changed files
with
62 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
export default async function (dir: string) { | ||
const mainRootDir = path.resolve(dir); | ||
|
||
const nextDirList = [mainRootDir]; | ||
const filesToBuild: string[] = []; | ||
|
||
let nextDir: string | undefined; | ||
while ((nextDir = nextDirList.shift())) { | ||
const files = await fs.promises.readdir(path.resolve(nextDir)); | ||
await Promise.all( | ||
files.map(async (fileName) => { | ||
const filePath = path.resolve(nextDir!, fileName); | ||
const fsStatus = await fs.promises.stat(filePath); | ||
if (fsStatus.isDirectory()) { | ||
nextDirList.push(filePath); | ||
} else if (filePath.endsWith('.js') || filePath.endsWith('.ts')) { | ||
filesToBuild.push(filePath); | ||
} | ||
}) | ||
); | ||
} | ||
|
||
return filesToBuild; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import constants from '../constants'; | ||
|
||
export default async function () { | ||
const mainRootDir = path.resolve(constants.scriptsCwd, 'src', 'main'); | ||
|
||
const nextDirList = [mainRootDir]; | ||
const filesToBuild: string[] = []; | ||
|
||
let nextDir: string | undefined; | ||
while ((nextDir = nextDirList.shift())) { | ||
const files = await fs.promises.readdir(path.resolve(nextDir)); | ||
files.map(async (fileName) => { | ||
const filePath = path.resolve(nextDir!, fileName); | ||
const fsStatus = await fs.promises.stat(filePath); | ||
if (fsStatus.isDirectory()) { | ||
nextDirList.push(filePath); | ||
} else if (filePath.endsWith('.js') || filePath.endsWith('.ts')) { | ||
filesToBuild.push(filePath); | ||
} | ||
}); | ||
} | ||
|
||
return filesToBuild; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters