File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { createHash } from 'node:crypto' ;
2- import { join } from 'node:path' ;
2+ import { join , resolve } from 'node:path' ;
33import type { BaseGeneratorConstructor , InputOutputAdapter } from '@yeoman/types' ;
44import { type YeomanNamespace , requireNamespace , toNamespace } from '@yeoman/namespace' ;
55import { flyImport } from 'fly-import' ;
@@ -343,11 +343,15 @@ class FullEnvironment extends EnvironmentBase {
343343 args = Array . isArray ( args ) ? args : splitArgsFromString ( args as unknown as string ) ;
344344 options = { ...options } ;
345345
346- const name = args . shift ( ) ;
346+ let name = args . shift ( ) ;
347347 if ( ! name ) {
348348 throw new Error ( 'Must provide at least one argument, the generator namespace to invoke.' ) ;
349349 }
350350
351+ if ( name . startsWith ( '.' ) ) {
352+ name = resolve ( name ) ;
353+ }
354+
351355 this . loadEnvironmentOptions ( options ) ;
352356
353357 if ( this . experimental && ! this . getGeneratorMeta ( name ) ) {
Original file line number Diff line number Diff line change 22import events from 'node:events' ;
33import fs from 'node:fs' ;
44import path , { dirname , join } from 'node:path' ;
5+ import process from 'node:process' ;
56import util from 'node:util' ;
67import { fileURLToPath } from 'node:url' ;
78import { createRequire } from 'node:module' ;
@@ -381,6 +382,20 @@ for (const generatorVersion of allVersions) {
381382 } ) ;
382383 } ) ;
383384
385+ describe ( 'using relative paths' , ( ) => {
386+ let oldCwd ;
387+ before ( ( ) => {
388+ oldCwd = process . cwd ( ) ;
389+ process . chdir ( dirname ( fileURLToPath ( import . meta. url ) ) ) ;
390+ } ) ;
391+ after ( ( ) => {
392+ process . chdir ( oldCwd ) ;
393+ } ) ;
394+ it ( 'runs a generator' , async function ( ) {
395+ return this . env . run ( [ './fixtures/generator-esm/generators/app/index.js' ] ) ;
396+ } ) ;
397+ } ) ;
398+
384399 it ( 'runs a registered writing generator with bail option' , async function ( ) {
385400 if ( isLegacyVersion ( generatorVersion ) ) {
386401 this . skip ( ) ;
You can’t perform that action at this time.
0 commit comments