Skip to content

Commit

Permalink
core: upgrade node-glob library
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocusinato committed Nov 8, 2024
1 parent 3ccc864 commit 7f82f37
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 76 deletions.
6 changes: 3 additions & 3 deletions arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"fast-safe-stringify": "^2.1.1",
"filename-reserved-regex": "^2.0.0",
"fqbn": "^1.0.5",
"glob": "^7.1.6",
"glob": "^11.0.0",
"google-protobuf": "^3.20.1",
"hash.js": "^1.1.7",
"is-online": "^10.0.0",
Expand Down Expand Up @@ -127,8 +127,8 @@
"rimraf": "^2.6.1"
},
"optionalDependencies": {
"grpc-tools": "^1.12.4",
"@pingghost/protoc": "^1.0.2"
"@pingghost/protoc": "^1.0.2",
"grpc-tools": "^1.12.4"
},
"mocha": {
"require": [
Expand Down
20 changes: 9 additions & 11 deletions arduino-ide-extension/scripts/generate-protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const path = require('node:path');
const { mkdirSync, promises: fs, rmSync } = require('node:fs');
const { exec } = require('./utils');
const glob = require('glob');
const { glob } = require('glob');
const { SemVer, gte, valid: validSemVer } = require('semver');
// Use a node-protoc fork until apple arm32 is supported
// https://github.com/YePpHa/node-protoc/pull/10
Expand Down Expand Up @@ -147,16 +147,14 @@
rmSync(out, { recursive: true, maxRetries: 5, force: true });
mkdirSync(out, { recursive: true });

const protos = await new Promise((resolve) =>
glob('**/*.proto', { cwd: rpc }, (error, matches) => {
if (error) {
console.log(error.stack ?? error.message);
resolve([]);
return;
}
resolve(matches.map((filename) => path.join(rpc, filename)));
})
);
let protos = [];
try {
const matches = await glob('**/*.proto', { cwd: rpc });
protos = matches.map((filename) => path.join(rpc, filename));
} catch (error) {
console.log(error.stack ?? error.message);
}

if (!protos || protos.length === 0) {
console.log(`Could not find any .proto files under ${rpc}.`);
process.exit(1);
Expand Down
12 changes: 2 additions & 10 deletions arduino-ide-extension/src/node/sketches-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { Mutable } from '@theia/core/lib/common/types';
import URI from '@theia/core/lib/common/uri';
import { FileUri } from '@theia/core/lib/node/file-uri';
import { inject, injectable, named } from '@theia/core/shared/inversify';
import glob from 'glob';
import crypto from 'node:crypto';
import {
CopyOptions,
Expand Down Expand Up @@ -50,6 +49,7 @@ import {
import { ServiceError } from './service-error';
import { SettingsReader } from './settings-reader';
import { ErrnoException } from './utils/errors';
import { glob } from 'glob';

const RecentSketches = 'recent-sketches.json';
const DefaultIno = `void setup() {
Expand Down Expand Up @@ -978,13 +978,5 @@ export async function discoverSketches(
}

async function globSketches(pattern: string, root: string): Promise<string[]> {
return new Promise<string[]>((resolve, reject) => {
glob(pattern, { root }, (error, results) => {
if (error) {
reject(error);
} else {
resolve(results);
}
});
});
return await glob(pattern, { root });
}
2 changes: 1 addition & 1 deletion electron-app/scripts/post-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const isCI = require('is-ci');
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const { glob } = require('glob');
const { isRelease } = require('./utils');
const { isZip, adjustArchiveStructure } = require('./archive');

Expand Down
Loading

0 comments on commit 7f82f37

Please sign in to comment.