Skip to content

Commit

Permalink
fix: don't wrap words in blockPackageJson description (#1874)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #1873
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

2af8204 shows the `\n` in the test.

💖
  • Loading branch information
JoshuaKGoldberg authored Jan 15, 2025
1 parent 3d651f2 commit e49f518
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 13 additions & 10 deletions src/next/blocks/blockPackageJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import { describe, expect, test } from "vitest";
import { blockPackageJson } from "./blockPackageJson.js";
import { optionsBase } from "./options.fakes.js";

const options = {
...optionsBase,
description: `A very very very very very very very very very very very very very very very very long <em><code>HTML-ish</code> description</em> ending with an emoji. 🧵`,
};

describe("blockPackageJson", () => {
test("without addons or mode", () => {
const creation = testBlock(blockPackageJson, {
options: optionsBase,
});
const creation = testBlock(blockPackageJson, { options });

expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"A very very very very very very very very very very very very very very very very long HTML-ish description ending with an emoji. 🧵","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
},
"scripts": [
{
Expand All @@ -30,13 +33,13 @@ describe("blockPackageJson", () => {
test("migration mode", () => {
const creation = testBlock(blockPackageJson, {
mode: "migrate",
options: optionsBase,
options,
});

expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"A very very very very very very very very very very very very very very very very long HTML-ish description ending with an emoji. 🧵","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
},
"scripts": [
{
Expand Down Expand Up @@ -67,13 +70,13 @@ describe("blockPackageJson", () => {
other: true,
},
},
options: optionsBase,
options,
});

expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"other":true}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"A very very very very very very very very very very very very very very very very long HTML-ish description ending with an emoji. 🧵","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"other":true}",
},
"scripts": [
{
Expand Down Expand Up @@ -102,13 +105,13 @@ describe("blockPackageJson", () => {
other: true,
},
},
options: optionsBase,
options,
});

expect(creation).toMatchInlineSnapshot(`
{
"files": {
"package.json": "{"name":"test-repository","version":"0.0.0","description":"Test description","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"devDependencies":{"is-even":"4.5.6"},"other":true}",
"package.json": "{"name":"test-repository","version":"0.0.0","description":"A very very very very very very very very very very very very very very very very long HTML-ish description ending with an emoji. 🧵","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"],"dependencies":{"is-odd":"1.2.3"},"devDependencies":{"is-even":"4.5.6"},"other":true}",
},
"scripts": [
{
Expand Down
4 changes: 3 additions & 1 deletion src/next/blocks/blockPackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const blockPackageJson = base.createBlock({
...options.packageData?.devDependencies,
...addons.properties.devDependencies,
};
const description = htmlToText.convert(options.description);
const description = htmlToText.convert(options.description, {
wordwrap: false,
});

return {
files: {
Expand Down

0 comments on commit e49f518

Please sign in to comment.