Fix incomplete render when --mode is used
This commit is contained in:
+35
-24
@@ -10,6 +10,7 @@ import {
|
|||||||
Cache,
|
Cache,
|
||||||
execUtils,
|
execUtils,
|
||||||
hashUtils,
|
hashUtils,
|
||||||
|
InstallMode,
|
||||||
LocatorHash,
|
LocatorHash,
|
||||||
Package,
|
Package,
|
||||||
Project,
|
Project,
|
||||||
@@ -22,8 +23,12 @@ import projectExprTmpl from "./tmpl/yarn-project.nix.in";
|
|||||||
import { tmpdir } from "os";
|
import { tmpdir } from "os";
|
||||||
|
|
||||||
// Generator function that runs after `yarn install`.
|
// Generator function that runs after `yarn install`.
|
||||||
export default async (project: Project, cache: Cache, report: Report) => {
|
export default async (
|
||||||
|
project: Project,
|
||||||
|
opts: { cache: Cache; report: Report; mode?: InstallMode }
|
||||||
|
) => {
|
||||||
const { configuration, cwd } = project;
|
const { configuration, cwd } = project;
|
||||||
|
const { cache, report } = opts;
|
||||||
|
|
||||||
// This case happens with `yarn dlx`, for example, and may cause errors if
|
// This case happens with `yarn dlx`, for example, and may cause errors if
|
||||||
// special settings don't apply to those installations. (Like a `nixExprPath`
|
// special settings don't apply to those installations. (Like a `nixExprPath`
|
||||||
@@ -267,30 +272,36 @@ export default async (project: Project, cache: Cache, report: Report) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the Nix expression.
|
// Render the Nix expression.
|
||||||
const ident = project.topLevelWorkspace.manifest.name;
|
//
|
||||||
const projectName = ident ? structUtils.stringifyIdent(ident) : `workspace`;
|
// If isolated builds are used, we rely on the build state, so don't render
|
||||||
const projectExpr = renderTmpl(projectExprTmpl, {
|
// if a special `--mode` was specified. This is because skipping builds may
|
||||||
PROJECT_NAME: json(projectName),
|
// give us an incomplete build state.
|
||||||
YARN_PATH: yarnPathRel,
|
if (opts.mode == null || isolatedBuilds.length === 0) {
|
||||||
LOCKFILE: lockfileRel,
|
const ident = project.topLevelWorkspace.manifest.name;
|
||||||
CACHE_FOLDER: json(cacheFolder),
|
const projectName = ident ? structUtils.stringifyIdent(ident) : `workspace`;
|
||||||
CACHE_ENTRIES: cacheEntriesCode,
|
const projectExpr = renderTmpl(projectExprTmpl, {
|
||||||
ISOLATED: isolatedCode.join("\n"),
|
PROJECT_NAME: json(projectName),
|
||||||
ISOLATED_INTEGRATION: indent(" ", isolatedIntegration.join("\n")),
|
YARN_PATH: yarnPathRel,
|
||||||
NEED_ISOLATED_BUILD_SUPPRORT: isolatedIntegration.length > 0,
|
LOCKFILE: lockfileRel,
|
||||||
});
|
CACHE_FOLDER: json(cacheFolder),
|
||||||
await xfs.writeFilePromise(configuration.get(`nixExprPath`), projectExpr);
|
CACHE_ENTRIES: cacheEntriesCode,
|
||||||
|
ISOLATED: isolatedCode.join("\n"),
|
||||||
|
ISOLATED_INTEGRATION: indent(" ", isolatedIntegration.join("\n")),
|
||||||
|
NEED_ISOLATED_BUILD_SUPPRORT: isolatedIntegration.length > 0,
|
||||||
|
});
|
||||||
|
await xfs.writeFilePromise(configuration.get(`nixExprPath`), projectExpr);
|
||||||
|
|
||||||
// Create a wrapper if it does not exist yet.
|
// Create a wrapper if it does not exist yet.
|
||||||
if (configuration.get(`generateDefaultNix`)) {
|
if (configuration.get(`generateDefaultNix`)) {
|
||||||
const defaultExprPath = ppath.join(cwd, `default.nix` as Filename);
|
const defaultExprPath = ppath.join(cwd, `default.nix` as Filename);
|
||||||
const flakeExprPath = ppath.join(cwd, `flake.nix` as Filename);
|
const flakeExprPath = ppath.join(cwd, `flake.nix` as Filename);
|
||||||
if (!xfs.existsSync(defaultExprPath) && !xfs.existsSync(flakeExprPath)) {
|
if (!xfs.existsSync(defaultExprPath) && !xfs.existsSync(flakeExprPath)) {
|
||||||
await xfs.writeFilePromise(defaultExprPath, defaultExprTmpl);
|
await xfs.writeFilePromise(defaultExprPath, defaultExprTmpl);
|
||||||
report.reportInfo(
|
report.reportInfo(
|
||||||
0,
|
0,
|
||||||
`A minimal default.nix was created. You may want to customize it.`
|
`A minimal default.nix was created. You may want to customize it.`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ const plugin: Plugin<Hooks> = {
|
|||||||
opts.persistProject !== false &&
|
opts.persistProject !== false &&
|
||||||
project.configuration.get(`enableNixify`)
|
project.configuration.get(`enableNixify`)
|
||||||
) {
|
) {
|
||||||
await generate(project, opts.cache, opts.report);
|
await generate(project, opts);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user