Skip to content

Commit

Permalink
Fix watchOP1() and universal builds, update vue.js (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
landonepps committed Jun 12, 2023
1 parent 2dcba69 commit d4c228a
Show file tree
Hide file tree
Showing 4 changed files with 11,770 additions and 9,479 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
/op1fun-darwin-x64
/op1fun-darwin-universal
/dist
/op1fun-darwin-x64.zip
/op1fun-darwin-universal.zip
/.vscode
115 changes: 55 additions & 60 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ const mb = menubar({
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
},
width: 600
},
preloadWindow: true,
width: 600,
icon: path.join(__dirname, 'icon.png')
});

Expand Down Expand Up @@ -199,7 +199,7 @@ function ensureConnected() {
}
}

function watchOP1() {
async function watchOP1() {
if (watcher) {
watcher.close();
}
Expand All @@ -208,72 +208,67 @@ function watchOP1() {
patches = [];
}

return new Promise((resolve, reject) => {

drivelist.list((error, drives) => {
if (error) { reject(error); }
try {
const drives = await drivelist.list();

for (var i = 0; i < drives.length; i++) {
if (drives[i].description.indexOf("OP-1") > -1) {
var m = drives[i].mountpoints[0];
if (m) {
mountpoint = m.path;
break;
}
for (let i = 0; i < drives.length; i++) {
if (drives[i].description.indexOf("OP-1") > -1) {
const m = drives[i].mountpoints[0];
if (m) {
mountpoint = m.path;
break;
}
}
}

if (!mountpoint) {
mounted = false;
return reject("OP-1 not found");
} else {
mounted = true;
}
if (!mountpoint) {
mounted = false;
throw new Error("OP-1 not found");
} else {
mounted = true;
}

watcher = chokidar.watch(mountpoint, {
ignored: /(^|[\/\\])\../,
awaitWriteFinish: true
}).on('all', (event, path) => {
if (mountpoint) {
var relPath = path.slice(mountpoint.length);
var parts = relPath.split("/");
if (
// ignore album, tape and user preset patches
((parts[1] === "synth") || (parts[1] === "drum")) && parts[2] != "user"
) {
if (event === 'add') {
try {
const patch = new OP1Patch({ path: path, relPath: relPath });
if (patch.metadata) {
patches.push(patch);
mb.window.webContents.send('render-patches', patches);
}
} catch (e) {
console.log(e);
watcher = chokidar.watch(mountpoint, {
ignored: /(^|[\/\\])\../,
awaitWriteFinish: true
}).on('all', (event, path) => {
if (mountpoint) {
const relPath = path.slice(mountpoint.length);
const parts = relPath.split("/");
if (
// ignore album, tape and user preset patches
((parts[1] === "synth") || (parts[1] === "drum")) && parts[2] != "user"
) {
if (event === 'add') {
try {
const patch = new OP1Patch({ path: path, relPath: relPath });
if (patch.metadata) {
patches.push(patch);
mb.window.webContents.send('render-patches', patches);
}
} else if (event === 'unlink') {
patches = patches.filter(function (p) { return p.relPath !== relPath });
mb.window.webContents.send('render-patches', patches);
} catch (e) {
console.log(e);
}
} else {
// console.log(event, path);
} else if (event === 'unlink') {
patches = patches.filter(function (p) { return p.relPath !== relPath });
mb.window.webContents.send('render-patches', patches);
}
} else {
// console.log(event, path);
}
}).on('raw', function (event, path, details) {
if (
(details.event === 'root-changed') ||
(details.event === 'deleted' && path === mountpoint)
) {
mountpoint = null;
mounted = false; // treat this as a disconnect
}
});

resolve(watcher);

}
}).on('raw', function (event, path, details) {
if (
(details.event === 'root-changed') ||
(details.event === 'deleted' && path === mountpoint)
) {
mountpoint = null;
mounted = false; // treat this as a disconnect
}
});


})

return watcher;
} catch (error) {
return Promise.reject(error);
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
},
"scripts": {
"start": "npm install && electron .",
"dist": "npm install && electron-rebuild && electron-packager . \"op1fun\" --platform=darwin --arch=x64 --app-bundle-id=\"com.fiftyfootfoghorn.op1fun\" --app-version=\"$(npm run --silent version)\" --build-version=\"$(npm run --silent version)\" --protocol op1fun --protocol-name \"op1.fun\" --overwrite --icon op1fun.icns --osx-sign.identity=\"Developer ID Application: Genuine Parts, LLC (S9R2U6487K)\" --ignore \"^op1fun-darwin-x64.*\"",
"clear": "rm -rf op1fun-darwin-x64 && rm -rf op1fun-darwin-x64.zip",
"dist": "npm install && electron-rebuild && electron-packager . \"op1fun\" --platform=darwin --arch=universal --osxUniversal.x64ArchFiles=\"*\" --app-bundle-id=\"com.fiftyfootfoghorn.op1fun\" --app-version=\"$(npm run --silent version)\" --build-version=\"$(npm run --silent version)\" --protocol op1fun --protocol-name \"op1.fun\" --overwrite --icon op1fun.icns --osx-sign.identity=\"Developer ID Application: Genuine Parts, LLC (S9R2U6487K)\" --ignore \"^op1fun-darwin-universal.*\"",
"clear": "rm -rf op1fun-darwin-universal && rm -rf op1fun-darwin-universal.zip",
"release": "npm version patch && npm run clear && npm run dist && npm run zip && npm run github-release",
"zip": "zip -rqy op1fun-darwin-x64.zip op1fun-darwin-x64",
"github-release": "hub release create v$(npm run --silent version) -a \"op1fun-darwin-x64.zip\" -m \"v$(npm run --silent version)\"",
"zip": "zip -rqy op1fun-darwin-universal.zip op1fun-darwin-universal",
"github-release": "hub release create v$(npm run --silent version) -a \"op1fun-darwin-universal.zip\" -m \"v$(npm run --silent version)\"",
"version": "node -p \"require('./package.json').version\""
},
"author": "Jordan Sitkin",
Expand Down
Loading

0 comments on commit d4c228a

Please sign in to comment.