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

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 +33 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -123,12 +123,37 @@ await Promise.all([
123
123
  console.log(result.status === "fulfilled" ? result.value : result.reason);
124
124
  });
125
125
  }),
126
- appendFile(`${process.cwd()}/.gitignore`, `
127
-
128
- # Testing tools
129
- /test-results/
130
- /playwright-report/
131
- /blob-report/
132
- /playwright/.cache/
133
- `),
126
+ readFile(`${process.cwd()}/.gitignore`)
127
+ .then((data) => {
128
+ return data.toString().split("\n");
129
+ })
130
+ .then((fileLines) => {
131
+ const linesToAddToGitignore = [
132
+ "/test-results/",
133
+ "/playwright-report/",
134
+ "/blob-report/",
135
+ "/playwright/.cache/",
136
+ ];
137
+ for (const line of linesToAddToGitignore) {
138
+ if (fileLines.includes(line)) {
139
+ linesToAddToGitignore.splice(linesToAddToGitignore.indexOf(line), 1);
140
+ }
141
+ }
142
+ return linesToAddToGitignore;
143
+ })
144
+ .then(async (linesToAddToGitignore) => {
145
+ if (linesToAddToGitignore.length === 0) {
146
+ return false;
147
+ }
148
+ await appendFile(`${process.cwd()}/.gitignore`, `\n# Testing tools\n${linesToAddToGitignore.join(`\n`)}`);
149
+ return true;
150
+ })
151
+ .then((wasFileUpdated) => {
152
+ if (wasFileUpdated) {
153
+ console.log(".gitignore updated");
154
+ }
155
+ else {
156
+ console.log(".gitignore not updated as all values are already in the file.");
157
+ }
158
+ }),
134
159
  ]);
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.3",
4
+ "version": "1.0.0-beta.4",
5
5
  "description": "Allow us to easily add automated testing setup to any npm setup.",
6
6
  "keywords": [
7
7
  "atomic",