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
2 changes: 1 addition & 1 deletion packages/zpm-constraints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ async function main() {

const output = applyEngineReport(FIX);

writeFileSync(RESULT_PATH, JSON.stringify(output, null, 2));
writeFileSync(RESULT_PATH, `${JSON.stringify(output, null, 2)}\n`);
}

main();
2 changes: 1 addition & 1 deletion packages/zpm-switch/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub async fn ensure<R: Future<Output = Result<(), Error>>, F: FnOnce(Path) -> R>
f(temp_dir.clone()).await?;

let meta_content
= JsonDocument::to_string(&key_data)?;
= format!("{}\n", JsonDocument::to_string(&key_data)?);

temp_dir
.with_join_str("meta.json")
Expand Down
2 changes: 1 addition & 1 deletion packages/zpm-switch/src/daemons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn register_daemon(entry: &DaemonEntry) -> Result<(), Error> {
.fs_create_parent()?;

let data
= JsonDocument::to_string(entry)?;
= format!("{}\n", JsonDocument::to_string(entry)?);

daemon_path.fs_write_atomic(move |tmp_path| {
use std::os::unix::fs::OpenOptionsExt;
Expand Down
2 changes: 1 addition & 1 deletion packages/zpm-switch/src/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn save_config(config: &FolderConfig) -> Result<(), Error> {

config_path
.fs_create_parent()?
.fs_write(JsonDocument::to_string(config)?)?;
.fs_write(format!("{}\n", JsonDocument::to_string(config)?))?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion packages/zpm/data/builtin-extensions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/zpm/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl BuildState {
.fs_create_parent()?;

let build_state_text
= JsonDocument::to_string(self)?;
= format!("{}\n", JsonDocument::to_string(self)?);

build_state_path
.fs_change(build_state_text, false)?;
Expand Down
2 changes: 1 addition & 1 deletion packages/zpm/src/builtins/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub async fn fetch_nodejs_locator<'a>(context: &InstallContext<'a>, locator: &Lo
};

let serialized_manifest
= JsonDocument::to_string(&manifest)?;
= format!("{}\n", JsonDocument::to_string(&manifest)?);

let entries
= zpm_formats::tar::entries_from_tar(&tar_data)?
Expand Down
2 changes: 1 addition & 1 deletion packages/zpm/src/commands/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Constraints {

if should_break {
if self.json {
println!("{}", String::from_utf8_lossy(&output.raw_json));
print!("{}", String::from_utf8_lossy(&output.raw_json));
}

if !output.all_workspace_errors.is_empty() {
Expand Down
3 changes: 2 additions & 1 deletion packages/zpm/src/constraints/constraints.tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@ async function main() {
const defaultConfig = config?.default ?? config;
await defaultConfig.constraints?.(context);
const output = applyEngineReport(FIX);
(0, import_fs.writeFileSync)(RESULT_PATH, JSON.stringify(output, null, 2));
(0, import_fs.writeFileSync)(RESULT_PATH, `${JSON.stringify(output, null, 2)}
`);
}
main();
2 changes: 1 addition & 1 deletion packages/zpm/src/linker/pnp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn generate_split_setup(project: &Project, state: &PnpState) -> Result<(), Error

project.pnp_data_path()
.fs_create_parent()?
.fs_change(JsonDocument::to_string(&state)?, false)?;
.fs_change(format!("{}\n", JsonDocument::to_string(&state)?), false)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion packages/zpm/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl Project {
= self.lockfile_path();

let contents
= JsonDocument::to_string_pretty(lockfile)?;
= format!("{}\n", JsonDocument::to_string_pretty(lockfile)?);

if self.config.settings.enable_immutable_installs.value {
let current_content = lockfile_path
Expand Down
2 changes: 1 addition & 1 deletion scripts/import-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ runExit(class ImportArtifactsCommand extends Command {
});

const entries = JSON.parse(dump);
const serialized = JSON.stringify(entries);
const serialized = `${JSON.stringify(entries)}\n`;

await fs.writeFile(outputPath, serialized);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ describe(`Commands`, () => {
}),
);

test(
`it should write a stable lockfile with a final newline`,
makeTemporaryEnv({}, async ({path, run}) => {
const lockfilePath = ppath.join(path, Filename.lockfile);

await run(`install`);
const lockfileContent = await xfs.readFilePromise(lockfilePath, `utf8`);
expect(lockfileContent).toMatch(/[^\n]\n$/);

await run(`install`, `--force`);
await run(`install`, `--immutable`);
expect(await xfs.readFilePromise(lockfilePath, `utf8`)).toEqual(lockfileContent);

const unterminatedContent = lockfileContent.slice(0, -1);
await xfs.writeFilePromise(lockfilePath, unterminatedContent);

await expect(run(`install`, `--immutable`)).rejects.toThrow(/The lockfile would have been modified by this install/);
expect(await xfs.readFilePromise(lockfilePath, `utf8`)).toEqual(unterminatedContent);

await run(`install`);
expect(await xfs.readFilePromise(lockfilePath, `utf8`)).toEqual(lockfileContent);
}),
);

test(
`it should refuse to create a lockfile when using --immutable`,
makeTemporaryEnv({
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18852,4 +18852,4 @@
}
}
}
}
}