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

Accounted for the location of the installed package #2

Merged
merged 1 commit into from
Jan 16, 2023
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
14 changes: 12 additions & 2 deletions src/migration/ember-addon/steps/create-files-from-blueprint.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import glob from 'glob';

import { createFiles } from '../../../utils/files.js';
import { processTemplate } from '../../../utils/process-template.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Comment on lines +10 to +11
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__dirname is unavailable in Node. An alternative came from https://stackoverflow.com/a/50052194.


function getBlueprintRoot() {
const codemodRoot = join(__dirname, '../../../..');

return join(codemodRoot, 'src/blueprints/ember-addon');
}

function getFilePath(blueprintFilePath, options) {
const { locations } = options;

Expand Down Expand Up @@ -36,7 +46,7 @@ function getFilesToSkip(options) {
}

export function createFilesFromBlueprint(context, options) {
const blueprintRoot = 'src/blueprints/ember-addon';
const blueprintRoot = getBlueprintRoot();

const filesToSkip = getFilesToSkip(options);

Expand Down