forked from fuse-open/uno
-
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 fuse-open#436 from mortend/net6-restore
update pack/restore for net6.0 (beta-3.0)
- Loading branch information
Showing
2 changed files
with
26 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const fs = require("fs") | ||
const path = require("path") | ||
|
||
function findup(suffix) { | ||
for (let dir = __dirname, parent = undefined;; | ||
dir = path.dirname(dir)) { | ||
|
||
if (dir == parent) | ||
throw Error(`${suffix} was not found`); | ||
throw Error(`${suffix} was not found`) | ||
|
||
parent = dir; | ||
const file = path.join(dir, suffix); | ||
parent = dir | ||
const file = path.join(dir, suffix) | ||
|
||
if (fs.existsSync(file)) | ||
return file; | ||
return file | ||
} | ||
} | ||
|
||
function findNodeModule(name) { | ||
const package = findup(`node_modules/${name}/package.json`); | ||
return path.dirname(package); | ||
const package = findup(`node_modules/${name}/package.json`) | ||
return path.dirname(package) | ||
} | ||
|
||
function restoreFiles(src, dst) { | ||
if (!fs.existsSync(dst)) | ||
return; | ||
return | ||
|
||
for (file of fs.readdirSync(src)) { | ||
const srcf = path.join(src, file); | ||
const dstf = path.join(dst, file); | ||
const placeholder = dstf + ".restore"; | ||
const srcf = path.join(src, file) | ||
const dstf = path.join(dst, file) | ||
const placeholder = dstf + ".restore" | ||
|
||
if (!fs.existsSync(placeholder)) | ||
continue; | ||
continue | ||
|
||
const relative = path.relative(process.cwd(), dstf); | ||
console.log(`restoring ${relative}`); | ||
fs.copyFileSync(srcf, dstf); | ||
fs.unlinkSync(placeholder); | ||
const relative = path.relative(process.cwd(), dstf) | ||
console.log(`restoring ${relative}`) | ||
fs.copyFileSync(srcf, dstf) | ||
fs.unlinkSync(placeholder) | ||
} | ||
} | ||
|
||
// Restore Xamarin.Mac binaries. | ||
const xamarin = findNodeModule("@fuse-open/xamarin-mac"); | ||
restoreFiles(xamarin, path.join(__dirname, "..", "bin")); | ||
restoreFiles(xamarin, path.join(__dirname, "..", "bin", "mac")); | ||
const xamarin = findNodeModule("@fuse-open/xamarin-mac") | ||
restoreFiles(xamarin, path.join(__dirname, "..", "bin", "net6.0")) | ||
restoreFiles(xamarin, path.join(__dirname, "..", "bin", "mac", "net6.0")) | ||
|
||
// Restore OpenTK and ANGLE (Windows only). | ||
const opentk = findNodeModule("@fuse-open/opentk"); | ||
restoreFiles(opentk, path.join(__dirname, "..", "bin", "win")); | ||
const opentk = findNodeModule("@fuse-open/opentk") | ||
restoreFiles(opentk, path.join(__dirname, "..", "bin", "win", "net6.0-windows")) |