Skip to content

Commit

Permalink
fix: scrapy wrapping being broken due to ESM migration (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfrangu committed Oct 25, 2024
1 parent 7e34bbe commit 7c9646b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/projects/scrapy/wrapScrapyProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
writeFileSync,
} from 'node:fs';
import { basename, join, relative, sep } from 'node:path';
import { fileURLToPath } from 'node:url';

import { fetchManifest, wrapperManifestUrl } from '@apify/actor-templates';
import rootWalk from '@root/walk';
Expand All @@ -25,6 +26,8 @@ import { downloadAndUnzip, sanitizeActorName } from '../../utils.js';
*/
const concatenableFiles = ['.dockerignore', '.gitignore'];

const templatePath = fileURLToPath(new URL('./templates/python-scrapy', import.meta.url));

async function merge(
fromPath: string,
toPath: string,
Expand Down Expand Up @@ -120,7 +123,6 @@ export async function wrapScrapyProject({ projectPath }: { projectPath?: string
info({ message: 'Downloading the latest Scrapy wrapper template...' });

const { archiveUrl } = manifest.templates.find(({ id }) => id === 'python-scrapy')!;
const templatePath = join(__dirname, 'templates', 'python-scrapy');

if (existsSync(templatePath)) rmSync(templatePath, { recursive: true });

Expand All @@ -131,7 +133,7 @@ export async function wrapScrapyProject({ projectPath }: { projectPath?: string

info({ message: 'Wrapping the Scrapy project...' });

await merge(join(__dirname, 'templates', 'python-scrapy'), projectPath, {
await merge(templatePath, projectPath, {
bindings: templateBindings,
});

Expand Down

0 comments on commit 7c9646b

Please sign in to comment.