Skip to content

Commit

Permalink
refactor: update-versions.js script to use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko committed Nov 22, 2024
1 parent 8a161cd commit f1008b4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
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

0 comments on commit f1008b4

Please sign in to comment.