Skip to content

Commit

Permalink
Add externs for external JS libs to prevent name been munged when bui…
Browse files Browse the repository at this point in the history
…lding with release
  • Loading branch information
kailes authored and tiensonqin committed Jan 7, 2021
1 parent 14e4af2 commit a335b97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions externs.js
Expand Up @@ -50,3 +50,15 @@ dummy.values = function() {};
// Do we really need those?
dummy.filter = function() {};
dummy.concat = function() {};

/**
* @typedef {{
* recursive: (undefined | boolean),
* }}
*/
var openDirectoryOptions;
/**
* @param {(undefined | openDirectoryOptions)} options
* @param {function} cb
*/
var openDirectory = function(options, cb) {};
6 changes: 3 additions & 3 deletions src/main/frontend/utils.js
Expand Up @@ -128,10 +128,10 @@ export var verifyPermission = async function (handle, readWrite) {
throw new Error("Permission is not granted");
}

// NOTE: Need externs to prevent `options.recursive` been munged
// When building with release.
export var openDirectory = async function (options = {}, cb) {
// FIXME: options.recursive will be undefined after the `getFiles` call get resolved
// It's caused by bumping shadow-cljs to 2.11.11.
options.recursive = true;
options.recursive = options.recursive || false;
const handle = await window.showDirectoryPicker({ mode: 'readwrite' });
const _ask = await verifyPermission(handle, true);
return [handle, getFiles(handle, options.recursive, cb)];
Expand Down

0 comments on commit a335b97

Please sign in to comment.