@sapphire-sh/utils 3.2.0 → 3.4.0

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.
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { spawnSync } from 'node:child_process';
3
4
  import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
4
5
  import { basename, dirname, join } from 'node:path';
5
6
  import { fileURLToPath } from 'node:url';
@@ -136,16 +137,26 @@ const writeWorkflow = (outputName, template) => {
136
137
  const writeDependabotConfig = (outputName, template) => {
137
138
  const filepath = join(cwd, outputName);
138
139
  const manifestDirectories = [];
139
- const pendingDirectories = [''];
140
+ const trackedFiles = spawnSync('git', ['ls-files', '-z'], { cwd, encoding: 'utf-8' });
140
141
 
141
- while (pendingDirectories.length > 0) {
142
- const relativeDirectory = pendingDirectories.pop();
142
+ if (trackedFiles.status === 0) {
143
+ for (const path of trackedFiles.stdout.split('\0')) {
144
+ if (basename(path) === 'package.json' && dirname(path) !== '.') {
145
+ manifestDirectories.push(`/${dirname(path)}`);
146
+ }
147
+ }
148
+ } else {
149
+ const pendingDirectories = [''];
150
+
151
+ while (pendingDirectories.length > 0) {
152
+ const relativeDirectory = pendingDirectories.pop();
143
153
 
144
- for (const entry of readdirSync(join(cwd, relativeDirectory), { withFileTypes: true })) {
145
- if (entry.isDirectory() && entry.name !== 'node_modules' && entry.name !== '.git') {
146
- pendingDirectories.push(relativeDirectory === '' ? entry.name : `${relativeDirectory}/${entry.name}`);
147
- } else if (entry.isFile() && entry.name === 'package.json' && relativeDirectory !== '') {
148
- manifestDirectories.push(`/${relativeDirectory}`);
154
+ for (const entry of readdirSync(join(cwd, relativeDirectory), { withFileTypes: true })) {
155
+ if (entry.isDirectory() && entry.name !== 'node_modules' && entry.name !== '.git') {
156
+ pendingDirectories.push(relativeDirectory === '' ? entry.name : `${relativeDirectory}/${entry.name}`);
157
+ } else if (entry.isFile() && entry.name === 'package.json' && relativeDirectory !== '') {
158
+ manifestDirectories.push(`/${relativeDirectory}`);
159
+ }
149
160
  }
150
161
  }
151
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire-sh/utils",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "@sapphire-sh/utils",
5
5
  "type": "module",
6
6
  "sideEffects": false,