From 8e4c77437c3befc809db4633c9a4d7b2e9ccb089 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Thu, 3 Mar 2022 15:14:51 +0700 Subject: [PATCH] fix(yarn3): Update cwd for yarn 1 backwards compatibility in bins --- packages/api/src/bins/redwood.ts | 6 +++++- packages/api/src/bins/rwfw.ts | 6 +++++- packages/core/src/bins/redwood.ts | 5 +++++ packages/core/src/bins/rwfw.ts | 5 +++++ packages/web/src/bins/redwood.ts | 6 +++++- packages/web/src/bins/rwfw.ts | 6 +++++- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/api/src/bins/redwood.ts b/packages/api/src/bins/redwood.ts index e49a3cff6b30..85ae67315e48 100644 --- a/packages/api/src/bins/redwood.ts +++ b/packages/api/src/bins/redwood.ts @@ -7,5 +7,9 @@ const requireFromCli = createRequire( const bins = requireFromCli('./package.json')['bin'] -process.chdir('../') +// Ensure we run all commands from the base of the RW project +// even if you invoke from ./web or ./api +const rwProjectRoot = requireFromCli('./dist/lib/index.js').getPaths().base +process.chdir(rwProjectRoot) + requireFromCli(bins['redwood']) diff --git a/packages/api/src/bins/rwfw.ts b/packages/api/src/bins/rwfw.ts index 8b9219d10323..65f65a6fb863 100644 --- a/packages/api/src/bins/rwfw.ts +++ b/packages/api/src/bins/rwfw.ts @@ -7,5 +7,9 @@ const requireFromCli = createRequire( const bins = requireFromCli('./package.json')['bin'] -process.chdir('../') +// Ensure we run all commands from the base of the RW project +// even if you invoke from ./web or ./api +const rwProjectRoot = requireFromCli('./dist/lib/index.js').getPaths().base +process.chdir(rwProjectRoot) + requireFromCli(bins['rwfw']) diff --git a/packages/core/src/bins/redwood.ts b/packages/core/src/bins/redwood.ts index 4c1d6985a18d..6f57d1d25a11 100644 --- a/packages/core/src/bins/redwood.ts +++ b/packages/core/src/bins/redwood.ts @@ -29,4 +29,9 @@ const requireFromCli = createRequire( const bins = requireFromCli('./package.json')['bin'] +// Ensure we run all commands from the base of the RW project +// even if you invoke from ./web or ./api +const rwProjectRoot = requireFromCli('./dist/lib/index.js').getPaths().base +process.chdir(rwProjectRoot) + requireFromCli(bins['redwood']) diff --git a/packages/core/src/bins/rwfw.ts b/packages/core/src/bins/rwfw.ts index 3e613a4a674f..65f65a6fb863 100644 --- a/packages/core/src/bins/rwfw.ts +++ b/packages/core/src/bins/rwfw.ts @@ -7,4 +7,9 @@ const requireFromCli = createRequire( const bins = requireFromCli('./package.json')['bin'] +// Ensure we run all commands from the base of the RW project +// even if you invoke from ./web or ./api +const rwProjectRoot = requireFromCli('./dist/lib/index.js').getPaths().base +process.chdir(rwProjectRoot) + requireFromCli(bins['rwfw']) diff --git a/packages/web/src/bins/redwood.ts b/packages/web/src/bins/redwood.ts index e49a3cff6b30..85ae67315e48 100644 --- a/packages/web/src/bins/redwood.ts +++ b/packages/web/src/bins/redwood.ts @@ -7,5 +7,9 @@ const requireFromCli = createRequire( const bins = requireFromCli('./package.json')['bin'] -process.chdir('../') +// Ensure we run all commands from the base of the RW project +// even if you invoke from ./web or ./api +const rwProjectRoot = requireFromCli('./dist/lib/index.js').getPaths().base +process.chdir(rwProjectRoot) + requireFromCli(bins['redwood']) diff --git a/packages/web/src/bins/rwfw.ts b/packages/web/src/bins/rwfw.ts index 8b9219d10323..65f65a6fb863 100644 --- a/packages/web/src/bins/rwfw.ts +++ b/packages/web/src/bins/rwfw.ts @@ -7,5 +7,9 @@ const requireFromCli = createRequire( const bins = requireFromCli('./package.json')['bin'] -process.chdir('../') +// Ensure we run all commands from the base of the RW project +// even if you invoke from ./web or ./api +const rwProjectRoot = requireFromCli('./dist/lib/index.js').getPaths().base +process.chdir(rwProjectRoot) + requireFromCli(bins['rwfw'])