setup: support generating flatpak sources from windows

This commit is contained in:
Abdullah Atta
2023-08-09 16:56:29 +05:00
parent e509c82807
commit 3450f2d19d

View File

@@ -16,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import fs from "fs/promises";
import fsSync from "fs";
import path from "path";
@@ -24,6 +23,7 @@ import { spawnSync } from "child_process";
import { fileURLToPath } from "url";
async function move(from, to) {
if (!fsSync.existsSync(from) || fsSync.existsSync(to)) return;
try {
await fs.rename(from, to);
} catch {
@@ -103,9 +103,22 @@ for (const lockfile of lockfiles) {
console.log("writing sources");
for (const source of allSources) {
for (let key in source) {
const value = source[key];
if (typeof value === "string" && value.includes("\\"))
source[key] = source[key].replace(/\\/gm, "/");
else if (Array.isArray(value)) {
value.forEach((elem, index) => {
value[index] = elem.replace(/\\/gm, "/");
});
}
}
}
await fs.writeFile(
"generated-sources.json",
JSON.stringify(allSources, undefined, 4)
);
console.log("done");
console.log("done");