-
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.
- Loading branch information
Showing
4 changed files
with
45 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
import * as fs from 'fs'; | ||
import * as fs from 'fs/promises'; | ||
import pkg from '../deep.json' assert { type: 'json' }; | ||
|
||
const encoding = 'utf8'; | ||
|
||
const [installCode] = pkg.data.filter(l => l.id === "installCode"); | ||
installCode.value.value = fs.readFileSync('handlers/install-code.ts', encoding); | ||
async function handlers2deepJson() { | ||
const operations = []; | ||
const installCode = pkg.data.find(l => l.id === "installCode"); | ||
if (installCode && installCode.value) { | ||
operations.push((async () => { | ||
installCode.value.value = await fs.readFile('handlers/install-code.ts', encoding); | ||
})()); | ||
} | ||
const publishCode = pkg.data.find(l => l.id === "publishCode"); | ||
if (publishCode && publishCode.value) { | ||
operations.push((async () => { | ||
publishCode.value.value = await fs.readFile('handlers/publish-code.ts', encoding); | ||
})()); | ||
} | ||
await Promise.all(operations); | ||
|
||
const [publishCode] = pkg.data.filter(l => l.id === "publishCode"); | ||
publishCode.value.value = fs.readFileSync('handlers/publish-code.ts', encoding); | ||
await fs.writeFile('deep.json', JSON.stringify(pkg, null, 2), encoding); | ||
|
||
fs.writeFileSync('deep.json', JSON.stringify(pkg, null, 2), encoding); | ||
console.log('deep.json build complete (code of handlers from `./handlers` is embedded into deep.json)'); | ||
} | ||
|
||
console.log('deep.json build complete'); | ||
handlers2deepJson().catch(console.error); |
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,21 @@ | ||
import * as fs from 'fs/promises'; | ||
import pkg from '../deep.json' assert { type: 'json' }; | ||
|
||
const encoding = 'utf8'; | ||
|
||
async function deepJson2handlers() { | ||
const operations = []; | ||
const installCode = pkg.data.find(l => l.id === "installCode"); | ||
if (installCode && installCode.value) { | ||
operations.push(fs.writeFile('handlers/install-code.ts', installCode.value.value, encoding)); | ||
} | ||
const publishCode = pkg.data.find(l => l.id === "publishCode"); | ||
if (publishCode && publishCode.value) { | ||
operations.push(fs.writeFile('handlers/publish-code.ts', publishCode.value.value, encoding)); | ||
} | ||
await Promise.all(operations); | ||
|
||
console.log('`deep.json` unbuild complete (handlers are extracted from `deep.json` to `./handlers`)'); | ||
} | ||
|
||
deepJson2handlers().catch(console.error); |
Oops, something went wrong.