diff --git a/src/commands/generate.ts b/src/commands/generate.ts index e5afc5c..ed06468 100644 --- a/src/commands/generate.ts +++ b/src/commands/generate.ts @@ -17,7 +17,7 @@ function createComponent(component: string, name: string, config: any, configLoc if (!projectLanguage) return reject(new Error("There is no 'projectLanguage' field in .sapphirerc.json")); const template = `${component.toLowerCase()}.${projectLanguage}.sapphire`; - const corePath = `${componentsFolder.pathname}${template}`; + const corePath = `${componentsFolder}${template}`; const userPath = config.customFileTemplates.enabled ? join(configLoc, config.customFileTemplates.location, template) : null; const target = join(configLoc, config.locations.base, '%L%', `${name}.${projectLanguage}`); const params = { name: basename(name) }; diff --git a/src/commands/new.ts b/src/commands/new.ts index 3d55e49..22f2c42 100644 --- a/src/commands/new.ts +++ b/src/commands/new.ts @@ -24,7 +24,7 @@ function editPackageJson(location: string, name: string) { } function installDeps(location: string, pm: string, verbose: boolean) { - const pmp = spawn(pm.toLowerCase(), ['install'], { + const pmp = spawn(process.platform === 'win32' ? `${pm.toLowerCase()}.cmd` : pm.toLowerCase(), ['install'], { stdio: verbose ? 'inherit' : undefined, cwd: `./${location}/` }); diff --git a/src/constants.ts b/src/constants.ts index d378897..eeb69f0 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,10 @@ -import { URL } from 'url'; +import { URL, fileURLToPath } from 'url'; -export const rootFolder = new URL('../', import.meta.url); -export const templatesFolder = new URL('./templates/', rootFolder); -export const componentsFolder = new URL('./components/', templatesFolder); +const rootURL = new URL('../', import.meta.url); +const templatesURL = new URL('./templates/', rootURL); +const componentsURL = new URL('./components/', templatesURL); + +export const rootFolder = fileURLToPath(rootURL); +export const templatesFolder = fileURLToPath(templatesURL); +export const componentsFolder = fileURLToPath(componentsURL); export const repoUrl = 'https://github.com/sapphiredev/examples.git'; diff --git a/src/functions/CreateFileFromTemplate.ts b/src/functions/CreateFileFromTemplate.ts index 9b8cdb7..a8991cf 100644 --- a/src/functions/CreateFileFromTemplate.ts +++ b/src/functions/CreateFileFromTemplate.ts @@ -12,7 +12,7 @@ export function CreateFileFromTemplate( component = false ) { return new Promise(async (resolve, reject) => { - const location = custom ? template : `${templatesFolder.pathname}${template}`; + const location = custom ? template : `${templatesFolder}${template}`; const output = {} as { f: string;