extension-create 3.8.6 → 3.8.7

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/module.cjs +10 -7
  2. package/package.json +1 -1
package/dist/module.cjs CHANGED
@@ -765,21 +765,24 @@ const globalLines = [
765
765
  ];
766
766
  async function writeGitignore(projectPath) {
767
767
  const gitIgnorePath = external_path_namespaceObject.join(projectPath, '.gitignore');
768
- const fileHandle = await promises_namespaceObject.open(gitIgnorePath, 'a+').catch((err)=>{
768
+ const paths = new Set();
769
+ let currentContents = '';
770
+ currentContents = await promises_namespaceObject.readFile(gitIgnorePath, 'utf8').catch((err)=>{
771
+ if ('ENOENT' === err.code) return '';
769
772
  console.error(err);
770
773
  throw err;
771
774
  });
772
- const paths = new Set();
773
- for await (let line of fileHandle.readLines({
774
- autoClose: false
775
- })){
776
- line = line.trim();
775
+ for (const rawLine of currentContents.split(/\r?\n/)){
776
+ const line = rawLine.trim();
777
777
  if (0 !== line.length) paths.add(line);
778
778
  }
779
779
  const linesToAdd = globalLines.filter((line)=>!paths.has(line));
780
780
  while('' === linesToAdd[linesToAdd.length - 1])linesToAdd.pop();
781
+ if (0 === linesToAdd.length) return;
781
782
  console.log(writingGitIgnore());
782
- await fileHandle.appendFile(linesToAdd.join('\n')).catch((err)=>{
783
+ const shouldPrefixWithNewline = currentContents.length > 0 && !currentContents.endsWith('\n');
784
+ const contentToAppend = `${shouldPrefixWithNewline ? '\n' : ''}${linesToAdd.join('\n')}`;
785
+ await promises_namespaceObject.appendFile(gitIgnorePath, contentToAppend).catch((err)=>{
783
786
  console.error(err);
784
787
  throw err;
785
788
  });
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "dist"
25
25
  ],
26
26
  "name": "extension-create",
27
- "version": "3.8.6",
27
+ "version": "3.8.7",
28
28
  "description": "The standalone extension creation engine for Extension.js",
29
29
  "author": {
30
30
  "name": "Cezar Augusto",