Comments (2)
That's not a bug, and that's not something I think we should add complexity to support.
from berry.
As a workaround, I made a simple plugin to run prettier
after all installed:
import { cwd as cwdFunc, stdout, stdin, stderr } from 'process';
import { Configuration, Hooks, Project, scriptUtils } from '@yarnpkg/core';
import { getPluginConfiguration } from '@yarnpkg/cli';
import { PortablePath } from '@yarnpkg/fslib';
// The documentation says to use `const plugin: Plugin = {...}; export.default = plugin` but this
// does not work. Explicit `module.exports` does.
module.exports = {
factory: (): { hooks: Hooks } => ({
hooks: {
afterAllInstalled(project: Project): void {
void (async () => {
const cwd = cwdFunc() as PortablePath;
const configuration = await Configuration.find(cwd, getPluginConfiguration());
const { locator } = await Project.find(configuration, cwd);
const packageAccessibleBinaries = await scriptUtils.getPackageAccessibleBinaries(
locator,
{
project,
},
);
if (!packageAccessibleBinaries.get('prettier')) {
throw new Error('Prettier not found.');
}
const ret = await scriptUtils.executePackageAccessibleBinary(
locator,
'prettier',
['--log-level', 'error', '-w', 'package.json', '.yarnrc.yml'],
{ cwd, packageAccessibleBinaries, project, stderr, stdin, stdout },
);
if (ret !== 0) {
throw new Error(`Prettier returned non-zero: {ret}.`);
}
})();
},
},
}),
name: 'plugin-prettier-after-all-installed',
};
The reason for this is because I have a hook in pre-commit to check that yarn.lock
is valid against package.json
. The formatting done by Yarn leads to a false positive.
repos:
- hooks:
- entry: yarn install --check-cache --immutable
files: ^package\.json$
id: yarn-check-lock
language: system
name: check yarn.lock is up-to-date
pass_filenames: false
from berry.
Related Issues (20)
- [Feature?] - need install verbose to see where I'm installing from
- [Feature] Support non-JavaScript executables in "bin"
- [Bug?]: Executing yarn dlx fails with Yarn 4.3.1 for mismatch hashes as Corepack tries to download Yarn 4.1.1 to execute yarn dlx
- [Bug?]: Using @mui/x-data-grid-premium v7 produces emotion error HOT 2
- [Bug?]: Corepack failed to install yarn when yarnPath is set
- [Feature] run `yarn install` after `yarn patch-commit -s ..`
- [Bug]: yarn -C ignores package.json packageManager setting.
- [Bug?]: wrong peer dependencies reporting HOT 1
- [Bug?]: yarn npm audit IDs are not stable
- [Feature]: use terminal colors HOT 2
- [Bug?]: yarn with node-linker does not correctly install nested dependencies HOT 2
- [Feature] Alternative to Node.js experimental corepack to manage package manager version HOT 4
- [Bug?]: TimeoutOverflowWarning when running PnP project with mocked `Date.now()`
- [Feature] yarn install --yes HOT 1
- [Bug?]: Prepack script does not run on packages installed from git HOT 1
- [Bug?]: "ENOENT: no such file or directory, link ..." when configured for `nodeLinker: pnpm` and running in Docker with mounted filesystem HOT 3
- [Bug?]: yarn up does not update dependencies
- [Bug?]: `fs.watch` method returns incorrect object.
- [Bug?]: Types are not inferred correctly for dependency if type is from nested dependency
- [Bug?]: Error: EXDEV: cross-device link not permitted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from berry.