Skip to content
This repository has been archived by the owner on May 1, 2022. It is now read-only.

Use path.sep to fix windows build error #45

Merged
merged 1 commit into from
Feb 13, 2020
Merged
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
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ async function compile(
newSource = result.js.code;
}

const destPath = srcPath
.replace(/^src\//, 'dist/')
.replace(/.svelte$/, '.js');
const destPath = getDestPath(srcPath).replace(/.svelte$/, '.js');
// Create all ancestor directories for this file
await fs.mkdir(path.dirname(destPath), { recursive: true });
await fs.writeFile(destPath, newSource);
Expand All @@ -101,13 +99,17 @@ async function compile(
}

async function copyFile(srcPath: string): Promise<void> {
const destPath = srcPath.replace(/^src\//, 'dist/');
const destPath = getDestPath(srcPath);
// Create all ancestor directories for this file
await fs.mkdir(path.dirname(destPath), { recursive: true });
await fs.copyFile(srcPath, destPath);
console.info(`Copied asset ${destPath}`);
}

function getDestPath(srcPath: string): string {
return srcPath.replace(new RegExp(`^src\\${path.sep}`), `dist${path.sep}`);
}

// Update the import paths to correctly point to web_modules.
async function transform(destPath: string): Promise<void> {
try {
Expand Down