Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: update-versions.js script to use ESM #446

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ecdn",
"cdn"
],
"version": "1.0.0",
"version": "2.1.0",
"files": [
"dist",
"lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-core/src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const PACKAGE_VERSION = "1.0.0";
export const PACKAGE_VERSION = "2.1.0";

2 changes: 1 addition & 1 deletion packages/p2p-media-loader-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ecdn",
"cdn"
],
"version": "0.0.0",
"version": "2.1.0",
"type": "module",
"files": [
"lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-hlsjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p2p-media-loader-hlsjs",
"version": "1.0.0",
"version": "2.1.0",
"description": "P2P Media Loader hls.js integration",
"license": "Apache-2.0",
"author": "Novage",
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-shaka/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p2p-media-loader-shaka",
"version": "1.0.0",
"version": "2.1.0",
"description": "P2P Media Loader Shaka Player integration",
"license": "Apache-2.0",
"author": "Novage",
Expand Down
14 changes: 9 additions & 5 deletions scripts/update-versions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const fs = require("fs");
const path = require("path");
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const packages = [
"../packages/p2p-media-loader-core/package.json",
Expand All @@ -11,7 +15,7 @@ const packages = [
const versionFile = "../packages/p2p-media-loader-core/src/utils/version.ts";

function updateVersionFile(versionFilePath, newVersion) {
const fullPath = path.resolve(versionFilePath);
const fullPath = path.resolve(__dirname, versionFilePath);
let fileContent = fs.readFileSync(fullPath, "utf8");

fileContent = fileContent.replace(/"(.*?)"/, `"${newVersion}"`);
Expand All @@ -20,8 +24,8 @@ function updateVersionFile(versionFilePath, newVersion) {
}

function updateVersion(packagePath, newVersion) {
const fullPath = path.resolve(packagePath);
const packageJson = require(fullPath);
const fullPath = path.resolve(__dirname, packagePath);
const packageJson = JSON.parse(fs.readFileSync(fullPath, "utf8"));
const updatedPackageJson = { ...packageJson, version: newVersion };
fs.writeFileSync(
fullPath,
Expand Down