2023-06-18 03:57:02 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const {existsSync} = require(`fs`);
|
2024-06-21 15:02:56 +00:00
|
|
|
const {createRequire, register} = require(`module`);
|
2023-06-18 03:57:02 +00:00
|
|
|
const {resolve} = require(`path`);
|
2024-06-21 15:02:56 +00:00
|
|
|
const {pathToFileURL} = require(`url`);
|
2023-06-18 03:57:02 +00:00
|
|
|
|
|
|
|
const relPnpApiPath = "../../../.pnp.cjs";
|
|
|
|
|
|
|
|
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
|
|
|
|
const absRequire = createRequire(absPnpApiPath);
|
|
|
|
|
2024-06-21 15:02:56 +00:00
|
|
|
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
|
|
|
|
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
|
|
|
|
|
2023-06-18 03:57:02 +00:00
|
|
|
if (existsSync(absPnpApiPath)) {
|
|
|
|
if (!process.versions.pnp) {
|
2023-09-23 03:51:15 +00:00
|
|
|
// Setup the environment to be able to require prettier
|
2023-06-18 03:57:02 +00:00
|
|
|
require(absPnpApiPath).setup();
|
2024-06-21 15:02:56 +00:00
|
|
|
if (isPnpLoaderEnabled && register) {
|
|
|
|
register(pathToFileURL(absPnpLoaderPath));
|
|
|
|
}
|
2023-06-18 03:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-23 03:51:15 +00:00
|
|
|
// Defer to the real prettier your application uses
|
|
|
|
module.exports = absRequire(`prettier`);
|