-
-
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
10 changed files
with
105 additions
and
62 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,24 +1,37 @@ | ||
const { join, dirname } = require("path") | ||
const { renameSync, mkdirSync } = require("fs") | ||
const { renameSync, mkdirSync, existsSync } = require("fs") | ||
const { execFileSync } = require("child_process") | ||
|
||
const exeExtention = process.platform === "win32" ? ".exe" : "" | ||
const binName = `minijson${exeExtention}` | ||
|
||
const distFolder = join(dirname(dirname(__dirname)), "dist") | ||
const minijsonSource = join(distFolder, binName) | ||
|
||
const distPlatformFolder = join(distFolder, `${process.platform}-${process.arch}`) | ||
mkdirSync(distPlatformFolder, { recursive: true }) | ||
|
||
function stripBin(file) { | ||
if (process.platform === "win32") { | ||
return | ||
} | ||
return execFileSync(process.env.STRIP || "strip", [file, process.platform === "darwin" ? "-Sx" : "--strip-all"]) | ||
} | ||
stripBin(minijsonSource) | ||
|
||
mkdirSync(distPlatformFolder, { recursive: true }) | ||
|
||
// exe | ||
|
||
const exeExtention = process.platform === "win32" ? ".exe" : "" | ||
const binName = `minijson${exeExtention}` | ||
const minijsonSource = join(distFolder, binName) | ||
const minijsonDist = join(distPlatformFolder, binName) | ||
|
||
renameSync(minijsonSource, minijsonDist) | ||
if (existsSync(minijsonSource)) { | ||
stripBin(minijsonSource) | ||
renameSync(minijsonSource, minijsonDist) | ||
} | ||
|
||
// lib | ||
|
||
const libExtension = process.platform === "win32" ? ".dll" : ".so" | ||
const minijsonLibSource = join(distFolder, `minijson.node${libExtension}`) | ||
const minijsonLibDist = join(distPlatformFolder, `minijson.node`) | ||
|
||
if (existsSync(minijsonLibSource)) { | ||
renameSync(minijsonLibSource, minijsonLibDist) | ||
} |
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,9 @@ | ||
module minijson.node; | ||
|
||
import node_dlang; | ||
|
||
import minijson.lib : minifyString; | ||
|
||
private extern (C) void atStart (napi_env env) {} | ||
|
||
mixin exportToJs!(minifyString, MainFunction!atStart); |