Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Runs the `prepare` lifecycle of git dependencies even if `NODE_ENV` is set to `production`.

[#7398](https://github.com/yarnpkg/yarn/pull/7398) - [**John Firebaugh**](https://github.com/jfirebaugh)

- Fixes the `postversion` lifecycle method not being called when using `--no-git-tag-version`.

[#7154](https://github.com/yarnpkg/yarn/pull/7154) - [**Hampus Tågerud**](https://github.com/hampustagerud)
Expand Down
34 changes: 34 additions & 0 deletions __tests__/fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,40 @@ test('GitFetcher.fetch with prepare script', async () => {
expect(await fs.exists(path.join(dir, 'generated', 'prepublish'))).toBe(false);
});

test('GitFetcher.fetch with prepare script, NODE_ENV=production', async () => {
const NODE_ENV = process.env.NODE_ENV;
try {
process.env.NODE_ENV = 'production';
const dir = await mkdir('git-fetcher-with-prepare');
const fetcher = new GitFetcher(
dir,
{
type: 'git',
reference: 'https://github.com/Volune/test-js-git-repo',
hash: '0e56593e326069ed4bcec8126bb48a1891215c57',
registry: 'npm',
},
await Config.create(),
);
await fetcher.fetch();
const name = (await fs.readJson(path.join(dir, 'package.json'))).name;
expect(name).toBe('test-js-git-repo');
const dependencyName = (await fs.readJson(path.join(dir, 'dependency-package.json'))).name;
expect(dependencyName).toBe('beeper');
// The file "prepare.js" is not in "files" list
expect(await fs.exists(path.join(dir, 'prepare.js'))).toBe(false);
// Check the dependency with a bin script was correctly executed
expect(await fs.exists(path.join(dir, 'testscript.output.txt'))).toBe(true);
// Check executed lifecycle scripts
expect(await fs.exists(path.join(dir, 'generated', 'preinstall'))).toBe(true);
expect(await fs.exists(path.join(dir, 'generated', 'install'))).toBe(true);
expect(await fs.exists(path.join(dir, 'generated', 'postinstall'))).toBe(true);
expect(await fs.exists(path.join(dir, 'generated', 'prepublish'))).toBe(false);
} finally {
process.env.NODE_ENV = NODE_ENV;
}
});

test('TarballFetcher.fetch', async () => {
const dir = await mkdir('tarball-fetcher');
const fetcher = new TarballFetcher(
Expand Down
1 change: 1 addition & 0 deletions src/fetchers/git-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default class GitFetcher extends BaseFetcher {
binLinks: true,
cwd: prepareDirectory,
disablePrepublish: true,
production: false,
},
this.reporter,
),
Expand Down