Skip to content

Commit

Permalink
Merge pull request #364 from 2graphic/linux-package-manager
Browse files Browse the repository at this point in the history
Linux package manager
  • Loading branch information
slaymaker1907 authored May 10, 2017
2 parents 68c1448 + c2a5e50 commit 4d12066
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
21 changes: 14 additions & 7 deletions app/services/plugin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { PythonPluginLoader } from "sinap-python-loader";
const app = remote.app;
const LOG = getLogger("plugin.service");

export const PLUGIN_DIRECTORY = IS_PRODUCTION ? path.join(app.getPath("userData"), "plugins") : "./plugins";
export const PLUGIN_DIRECTORY = IS_PRODUCTION ? path.join(app.getPath("userData"), "plugins") : path.join(app.getAppPath(), "plugins");
export const ROOT_DIRECTORY = IS_PRODUCTION ? path.join(app.getAppPath(), "..", "app") : ".";

class PluginHolder {
Expand Down Expand Up @@ -210,12 +210,15 @@ export class PluginService {
let dirs: string[] = [];

try {
dirs = await subdirs(PLUGIN_DIRECTORY);
const unfiltered = await subdirs(PLUGIN_DIRECTORY);
for (const dir of unfiltered) {
const files = await dirFiles(dir);
if (files.findIndex(file => file === "package.json") >= 0)
dirs.push(dir);
}
} catch (err) {
if (err && err.code === "ENOENT") {
if (err && err.code === "ENOENT")
await createDir(PLUGIN_DIRECTORY);
dirs = [];
}
}

const plugins = await somePromises(dirs.map(dir => this.loadPlugin(dir)), LOG);
Expand Down Expand Up @@ -254,8 +257,12 @@ export class PluginService {
public async importPlugin(dir: string): Promise<void> {
// Recursively progress through directories until we get interpreter info.
const dest = path.join(PLUGIN_DIRECTORY, path.basename(dir));
LOG.log(`Importing plugins from ${dir} to ${dest}.`);
await copy(dir, dest);
if (dest === dir) {
return Promise.resolve();
} else {
LOG.log(`Importing plugins from ${dir} to ${dest}.`);
await copy(dir, dest);
}
}

public async unload(plugin: Plugin): Promise<void> {
Expand Down
23 changes: 8 additions & 15 deletions app/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,16 @@ export function getExpected(program: Program) {


// Similar to Promise.all. However, this will always resolve and ignore rejected promises.
export function somePromises<T>(promises: Iterable<Promise<T>>, logger: Logger): Promise<T[]> {
let result: Promise<T[]> = Promise.resolve([]);

export async function somePromises<T>(promises: Iterable<Promise<T>>, logger: Logger): Promise<T[]> {
const arr = [] as T[];
for (const promise of promises) {
result = result.then((arr) => {
return promise.then((ele) => {
arr.push(ele);
return arr;
}).catch((err) => {
logger.log(err);
return arr;
});
});
try {
arr.push(await promise);
} catch (err) {
logger.log(err);
}
}

return result;
return Promise.resolve(arr);
}

export function getPath(name: string) {
Expand Down Expand Up @@ -151,7 +145,6 @@ export async function requestOpenDirs(name?: string): Promise<string[]> {
const result = new NodePromise<string[]>();
dialog.showOpenDialog(remote.BrowserWindow.getFocusedWindow(), {
properties: ["openDirectory"],
filters: [ZIP_FILE_FILTER],
defaultPath: name
}, names => result.cb(names ? null : "Directory selection cancelled", names));

Expand Down
19 changes: 12 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ module.exports = (env = {}) => { // pass command line arguments like `webpack ..
plugins: [
new webpack.NoEmitOnErrorsPlugin(),

/*** # 5/9/2017 ***/
/*** See: https://github.com/webpack/webpack/issues/2545#issuecomment-300134407 ***/
/*** Removing uglify for the time being. ***/
/*** See also: https://github.com/webpack-contrib/uglifyjs-webpack-plugin ***/
/*** for up-to-date instructions on how to use the webpack uglify plugin. ***/
// Note because our project is ES6, we're using the harmony branch of uglifyjs
new webpack.optimize.UglifyJsPlugin({
debug: false,
minimize: true,
output: {
comments: false
},
}),
// new webpack.optimize.UglifyJsPlugin({
// debug: false,
// minimize: true,
// output: {
// comments: false
// },
// }),
]
};

Expand Down

0 comments on commit 4d12066

Please sign in to comment.