Skip to content
Open
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions .yarn/versions/b32850f7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/core": patch
"@yarnpkg/doctor": patch
"@yarnpkg/plugin-constraints": patch
"@yarnpkg/plugin-dlx": patch
"@yarnpkg/plugin-essentials": patch
"@yarnpkg/plugin-init": patch
"@yarnpkg/plugin-interactive-tools": patch
"@yarnpkg/plugin-npm-cli": patch
"@yarnpkg/plugin-pack": patch
"@yarnpkg/plugin-patch": patch
"@yarnpkg/plugin-pnp": patch
"@yarnpkg/plugin-stage": patch
"@yarnpkg/plugin-version": patch
"@yarnpkg/plugin-workspace-tools": patch

declined:
- "@yarnpkg/plugin-catalog"
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-jsr"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/builder"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,23 @@ describe(`DotEnv files`, () => {
stdout: `hello\n`,
});
}));

it(`should correctly resolve .env.yarn files from project root`, makeTemporaryEnv({}, async ({path, run, source}) => {
const subdir = ppath.join(path, `subdir`);
await xfs.mkdirPromise(subdir);

await xfs.writeFilePromise(ppath.join(subdir, `.env.yarn`), [
`INJECTED_FROM_SUBDIR_ENV_FILE=hello\n`,
].join(``));
await xfs.writeFilePromise(ppath.join(path, `.env.yarn`), [
`INJECTED_FROM_ENV_FILE=hello\n`,
].join(``));

await run(`install`);

const {stdout} = await run(`exec`, `env`, {cwd: subdir});

expect(stdout).toMatch(/^INJECTED_FROM_ENV_FILE=hello$/m);
expect(stdout).not.toMatch(/^INJECTED_FROM_SUBDIR_ENV_FILE=hello$/m);
}));
});
10 changes: 2 additions & 8 deletions packages/yarnpkg-core/sources/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ export class Configuration {
delete environmentSettings.rcFilename;

const configuration = new Configuration(startingCwd);
configuration.projectCwd = await Configuration.findProjectCwd(startingCwd);

const rcFiles = await Configuration.findRcFiles(startingCwd);

const homeRcFile = await Configuration.findFolderRcFile(folderUtils.getHomeFolder());
Expand Down Expand Up @@ -1239,17 +1241,9 @@ export class Configuration {
}
}

// We need to know the project root before being able to truly instantiate
// our configuration.

const projectCwd = await Configuration.findProjectCwd(startingCwd);

// Great! We now have enough information to really start to setup the
// core configuration object.

configuration.startingCwd = startingCwd;
configuration.projectCwd = projectCwd;

const env = Object.assign(Object.create(null), process.env);
configuration.env = env;

Expand Down
Loading