@atomicsmash/init-testing 1.0.0-beta.4 → 1.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +11 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -128,24 +128,28 @@ await Promise.all([
128
128
  return data.toString().split("\n");
129
129
  })
130
130
  .then((fileLines) => {
131
- const linesToAddToGitignore = [
131
+ const linesToCheck = [
132
132
  "/test-results/",
133
133
  "/playwright-report/",
134
134
  "/blob-report/",
135
135
  "/playwright/.cache/",
136
136
  ];
137
- for (const line of linesToAddToGitignore) {
138
- if (fileLines.includes(line)) {
139
- linesToAddToGitignore.splice(linesToAddToGitignore.indexOf(line), 1);
137
+ const linesToAddToGitignore = [];
138
+ for (const line of linesToCheck) {
139
+ if (!fileLines.includes(line)) {
140
+ linesToAddToGitignore.push(line);
140
141
  }
141
142
  }
142
- return linesToAddToGitignore;
143
+ return {
144
+ linesToAddToGitignore,
145
+ fileEndsWithEmptyLine: fileLines.at(-1) === "",
146
+ };
143
147
  })
144
- .then(async (linesToAddToGitignore) => {
148
+ .then(async ({ linesToAddToGitignore, fileEndsWithEmptyLine }) => {
145
149
  if (linesToAddToGitignore.length === 0) {
146
150
  return false;
147
151
  }
148
- await appendFile(`${process.cwd()}/.gitignore`, `\n# Testing tools\n${linesToAddToGitignore.join(`\n`)}`);
152
+ await appendFile(`${process.cwd()}/.gitignore`, `${fileEndsWithEmptyLine ? "\n" : "\n\n"}# Testing tools\n${linesToAddToGitignore.join(`\n`)}\n`);
149
153
  return true;
150
154
  })
151
155
  .then((wasFileUpdated) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atomicsmash/init-testing",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.4",
4
+ "version": "1.0.0-beta.6",
5
5
  "description": "Allow us to easily add automated testing setup to any npm setup.",
6
6
  "keywords": [
7
7
  "atomic",