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

fix: add sourcemaps #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 25 additions & 4 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,33 @@ const path = require('path');

let _projectRoot = null;

(async() => {
await fse.move(sourcePackage(),
targetPackage(),
{overwrite: true});
(async () => {
// Move the JavaScript file and its associated source map
await moveFileWithSourceMap(sourcePackage(), targetPackage());
})();

// Function to move the main package and its source map
async function moveFileWithSourceMap(sourceFilePath, targetFilePath) {
try {
// Move the main JavaScript file
await fse.move(sourceFilePath, targetFilePath, { overwrite: true });
console.log(`Moved: ${sourceFilePath} -> ${targetFilePath}`);

// Check if a source map exists and move it if found
const sourceMapPath = `${sourceFilePath}.map`;
const targetMapPath = `${targetFilePath}.map`;

if (fse.pathExists(sourceMapPath)) {
await fse.move(sourceMapPath, targetMapPath, { overwrite: true });
console.log(`Moved: ${sourceMapPath} -> ${targetMapPath}`);
} else {
console.log(`Source map not found for: ${sourceFilePath}`);
}
} catch (err) {
console.error(`Error moving files: ${err.message}`);
}
}

function projectRoot() {
if (!_projectRoot) {
_projectRoot = __dirname;
Expand Down