Skip to content

Commit

Permalink
fix: update destination path
Browse files Browse the repository at this point in the history
  • Loading branch information
Ar-mane committed May 12, 2024
1 parent f2bb21b commit 9836b9a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.41",
"version": "2.0.42",
"name": "component-maker",
"displayName": "Component Maker",
"publisher": "Ar-mane",
Expand Down
19 changes: 9 additions & 10 deletions src/domain/MainExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ import { ConfigLoader } from '@/domain/ConfigLoader';
import { TemplateManager } from '@/domain/TemplateManager';
import { Files } from '@/utility/Files';
import { getComponentDestincation } from '@/utility/fileUtility';
import { ExtensionContext, Uri } from 'vscode';
import { Uri } from 'vscode';

export class MainExtension {
private context: ExtensionContext;
private uri: Uri;

private constructor(context: ExtensionContext, uri: Uri) {
this.context = context;
private constructor(uri: Uri) {

this.uri = uri;
}

private setContext(context: ExtensionContext) {
this.context = context;
private setUri(uri: Uri) {
this.uri = uri;
}

async run() {
const configLoader = ConfigLoader.instance();
const dest = Files.toRelative(getComponentDestincation(this.uri));
await TemplateManager.instance(configLoader, dest).run();
await TemplateManager.instance(configLoader).run(dest);
}

// ______ singleton _______
private static instance: MainExtension | null = null;
public static from(context: ExtensionContext, uri: Uri): MainExtension {
public static from(uri: Uri): MainExtension {
if (this.instance === null) {
this.instance = new MainExtension(context, uri);
this.instance = new MainExtension(uri);
}
this.instance.setContext(context);
this.instance.setUri(uri);
return this.instance;
}
// ____ END singleton _____
Expand Down
13 changes: 7 additions & 6 deletions src/domain/TemplateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import {
export class TemplateManager {
private configLoader: ConfigLoader;
private config!: Config;
private destination: string;
private destination!: string;

private constructor(configLoader: ConfigLoader, destination: RelativePath) {
private constructor(configLoader: ConfigLoader) {
this.configLoader = configLoader;
this.destination = destination;
}

async run() {

async run(destination: RelativePath) {
this.destination = destination;
this.config = await this.configLoader.getConfig();
const template = await DialogManager.promptTemplateSelection(this.config);
const componentName = await DialogManager.promptComponentName();
Expand Down Expand Up @@ -76,9 +77,9 @@ export class TemplateManager {

// ______ singleton _______
private static _instance: TemplateManager | null = null;
public static instance(configLoader: ConfigLoader, destination: RelativePath): TemplateManager {
public static instance(configLoader: ConfigLoader): TemplateManager {
if (this._instance === null) {
this._instance = new TemplateManager(configLoader, destination);
this._instance = new TemplateManager(configLoader);
}
return this._instance;
}
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function activate(context: ExtensionContext) {
throw new TerminationError(TerminateReason.NoUriProvided);
}

await MainExtension.from(context, uri).run();
await MainExtension.from(uri).run();
DialogManager.displaySuccessNotification();
} catch (error) {
if (error instanceof TerminationError) {
Expand All @@ -28,4 +28,4 @@ export function activate(context: ExtensionContext) {
context.subscriptions.push(command);
}

export function deactivate() {}
export function deactivate() { }

0 comments on commit 9836b9a

Please sign in to comment.