mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-07 08:34:15 +01: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 break-all">{collection.pathname}</td>
|
||||
</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="">
|
||||
<td className="py-2 px-2 text-right">Environments :</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 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);
|
||||
ipcMain.emit('main:collection-opened', win, collectionPath, uid);
|
||||
ipcMain.emit('main:collection-opened', win, collectionPath, uid, brunoConfig);
|
||||
} catch (err) {
|
||||
if (!options.dontSendDisplayErrors) {
|
||||
win.webContents.send('main:display-error', {
|
||||
|
@ -403,17 +403,18 @@ class Watcher {
|
||||
this.watchers = {};
|
||||
}
|
||||
|
||||
addWatcher(win, watchPath, collectionUid) {
|
||||
addWatcher(win, watchPath, collectionUid, brunoConfig) {
|
||||
if (this.watchers[watchPath]) {
|
||||
this.watchers[watchPath].close();
|
||||
}
|
||||
|
||||
const ignores = brunoConfig?.ignore || [];
|
||||
const self = this;
|
||||
setTimeout(() => {
|
||||
const watcher = chokidar.watch(watchPath, {
|
||||
ignoreInitial: false,
|
||||
usePolling: watchPath.startsWith("\\\\") ? true : false,
|
||||
ignored: (path) => ['node_modules', '.git'].some((s) => path.includes(s)),
|
||||
usePolling: watchPath.startsWith('\\\\') ? true : false,
|
||||
ignored: (path) => ignores.some((s) => path.includes(s)),
|
||||
persistent: true,
|
||||
ignorePermissionErrors: true,
|
||||
awaitWriteFinish: {
|
||||
|
@ -70,13 +70,14 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
const brunoConfig = {
|
||||
version: '1',
|
||||
name: collectionName,
|
||||
type: 'collection'
|
||||
type: 'collection',
|
||||
ignore: ['node_modules', '.git']
|
||||
};
|
||||
const content = await stringifyJson(brunoConfig);
|
||||
await writeFile(path.join(dirPath, 'bruno.json'), content);
|
||||
|
||||
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) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
@ -449,13 +450,14 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
const brunoConfig = {
|
||||
version: '1',
|
||||
name: collectionName,
|
||||
type: 'collection'
|
||||
type: 'collection',
|
||||
ignore: ['node_modules', '.git']
|
||||
};
|
||||
const content = await stringifyJson(brunoConfig);
|
||||
await writeFile(path.join(collectionPath, 'bruno.json'), content);
|
||||
|
||||
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);
|
||||
|
||||
@ -612,8 +614,8 @@ const registerMainEventHandlers = (mainWindow, watcher, lastOpenedCollections) =
|
||||
shell.openExternal(docsURL);
|
||||
});
|
||||
|
||||
ipcMain.on('main:collection-opened', (win, pathname, uid) => {
|
||||
watcher.addWatcher(win, pathname, uid);
|
||||
ipcMain.on('main:collection-opened', (win, pathname, uid, brunoConfig) => {
|
||||
watcher.addWatcher(win, pathname, uid, brunoConfig);
|
||||
lastOpenedCollections.add(pathname);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user