mirror of
https://github.com/usebruno/bruno.git
synced 2025-05-03 21:04:24 +02:00
Introduces a new bruno.json configuration property named 'ignore' allowing to specify which files or folders should be ignored in the collection. (#1514)
Also makes sure the behavior of legacy collections is not altered. Fixes issue #1496
This commit is contained in:
parent
09e7ea0d4d
commit
cb95b5f36a
@ -33,6 +33,10 @@ const Info = ({ collection }) => {
|
|||||||
<td className="py-2 px-2 text-right">Location :</td>
|
<td className="py-2 px-2 text-right">Location :</td>
|
||||||
<td className="py-2 px-2 break-all">{collection.pathname}</td>
|
<td className="py-2 px-2 break-all">{collection.pathname}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr className="">
|
||||||
|
<td className="py-2 px-2 text-right">Ignored files :</td>
|
||||||
|
<td className="py-2 px-2 break-all">{collection.brunoConfig.ignore.map((x) => `'${x}'`).join(', ')}</td>
|
||||||
|
</tr>
|
||||||
<tr className="">
|
<tr className="">
|
||||||
<td className="py-2 px-2 text-right">Environments :</td>
|
<td className="py-2 px-2 text-right">Environments :</td>
|
||||||
<td className="py-2 px-2">{collection.environments?.length || 0}</td>
|
<td className="py-2 px-2">{collection.environments?.length || 0}</td>
|
||||||
|
@ -62,8 +62,13 @@ const openCollection = async (win, watcher, collectionPath, options = {}) => {
|
|||||||
const brunoConfig = await getCollectionConfigFile(collectionPath);
|
const brunoConfig = await getCollectionConfigFile(collectionPath);
|
||||||
const uid = generateUidBasedOnHash(collectionPath);
|
const uid = generateUidBasedOnHash(collectionPath);
|
||||||
|
|
||||||
|
if (!brunoConfig.ignore || brunoConfig.ignore.length === 0) {
|
||||||
|
// Forces default behavior for legacy collections
|
||||||
|
brunoConfig.ignore = ['node_modules', '.git'];
|
||||||
|
}
|
||||||
|
|
||||||
win.webContents.send('main:collection-opened', collectionPath, uid, brunoConfig);
|
win.webContents.send('main:collection-opened', collectionPath, uid, brunoConfig);
|
||||||
ipcMain.emit('main:collection-opened', win, collectionPath, uid);
|
ipcMain.emit('main:collection-opened', win, collectionPath, uid, brunoConfig);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!options.dontSendDisplayErrors) {
|
if (!options.dontSendDisplayErrors) {
|
||||||
win.webContents.send('main:display-error', {
|
win.webContents.send('main:display-error', {
|
||||||
|
@ -403,17 +403,18 @@ class Watcher {
|
|||||||
this.watchers = {};
|
this.watchers = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
addWatcher(win, watchPath, collectionUid) {
|
addWatcher(win, watchPath, collectionUid, brunoConfig) {
|
||||||
if (this.watchers[watchPath]) {
|
if (this.watchers[watchPath]) {
|
||||||
this.watchers[watchPath].close();
|
this.watchers[watchPath].close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ignores = brunoConfig?.ignore || [];
|
||||||
const self = this;
|
const self = this;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const watcher = chokidar.watch(watchPath, {
|
const watcher = chokidar.watch(watchPath, {
|
||||||
ignoreInitial: false,
|
ignoreInitial: false,
|
||||||
usePolling: watchPath.startsWith("\\\\") ? true : false,
|
usePolling: watchPath.startsWith('\\\\') ? true : false,
|
||||||
ignored: (path) => ['node_modules', '.git'].some((s) => path.includes(s)),
|
ignored: (path) => ignores.some((s) => path.includes(s)),
|
||||||
persistent: true,
|
persistent: true,
|
||||||
ignorePermissionErrors: true,
|
ignorePermissionErrors: true,
|
||||||
awaitWriteFinish: {
|
awaitWriteFinish: {
|
||||||
|
@ -70,13 +70,14 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
const brunoConfig = {
|
const brunoConfig = {
|
||||||
version: '1',
|
version: '1',
|
||||||
name: collectionName,
|
name: collectionName,
|
||||||
type: 'collection'
|
type: 'collection',
|
||||||
|
ignore: ['node_modules', '.git']
|
||||||
};
|
};
|
||||||
const content = await stringifyJson(brunoConfig);
|
const content = await stringifyJson(brunoConfig);
|
||||||
await writeFile(path.join(dirPath, 'bruno.json'), content);
|
await writeFile(path.join(dirPath, 'bruno.json'), content);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:collection-opened', dirPath, uid, brunoConfig);
|
mainWindow.webContents.send('main:collection-opened', dirPath, uid, brunoConfig);
|
||||||
ipcMain.emit('main:collection-opened', mainWindow, dirPath, uid);
|
ipcMain.emit('main:collection-opened', mainWindow, dirPath, uid, brunoConfig);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
@ -449,13 +450,14 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
const brunoConfig = {
|
const brunoConfig = {
|
||||||
version: '1',
|
version: '1',
|
||||||
name: collectionName,
|
name: collectionName,
|
||||||
type: 'collection'
|
type: 'collection',
|
||||||
|
ignore: ['node_modules', '.git']
|
||||||
};
|
};
|
||||||
const content = await stringifyJson(brunoConfig);
|
const content = await stringifyJson(brunoConfig);
|
||||||
await writeFile(path.join(collectionPath, 'bruno.json'), content);
|
await writeFile(path.join(collectionPath, 'bruno.json'), content);
|
||||||
|
|
||||||
mainWindow.webContents.send('main:collection-opened', collectionPath, uid, brunoConfig);
|
mainWindow.webContents.send('main:collection-opened', collectionPath, uid, brunoConfig);
|
||||||
ipcMain.emit('main:collection-opened', mainWindow, collectionPath, uid);
|
ipcMain.emit('main:collection-opened', mainWindow, collectionPath, uid, brunoConfig);
|
||||||
|
|
||||||
lastOpenedCollections.add(collectionPath);
|
lastOpenedCollections.add(collectionPath);
|
||||||
|
|
||||||
@ -612,8 +614,8 @@ const registerMainEventHandlers = (mainWindow, watcher, lastOpenedCollections) =
|
|||||||
shell.openExternal(docsURL);
|
shell.openExternal(docsURL);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('main:collection-opened', (win, pathname, uid) => {
|
ipcMain.on('main:collection-opened', (win, pathname, uid, brunoConfig) => {
|
||||||
watcher.addWatcher(win, pathname, uid);
|
watcher.addWatcher(win, pathname, uid, brunoConfig);
|
||||||
lastOpenedCollections.add(pathname);
|
lastOpenedCollections.add(pathname);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user