From 12007974bda9df3bbd949aab1aff86209a0b4169 Mon Sep 17 00:00:00 2001 From: Colin Mitchell Date: Mon, 11 Dec 2017 13:05:49 -0500 Subject: [PATCH] Fix issues with setting folder, creating screensaver --- package.json | 3 ++- src/lib/savers.js | 9 +------ .../__template/index.html | 0 .../__template/saver.json | 0 src/main/index.js | 25 ++++++++++++++++--- src/renderer/Prefs.vue | 17 ++++++++++++- src/renderer/components/PrefsForm.vue | 10 +++++--- test/lib/savers.js | 12 ++++++--- test/ui/prefs.js | 17 +++++++++++++ test/ui/setup.js | 6 +++++ webpack.main.config.js | 11 ++++++-- yarn.lock | 4 +++ 12 files changed, 91 insertions(+), 23 deletions(-) rename src/{system-savers => main}/__template/index.html (100%) rename src/{system-savers => main}/__template/saver.json (100%) diff --git a/package.json b/package.json index da51b5fe..f05698ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "before-dawn", "productName": "Before Dawn", - "version": "0.9.13", + "version": "0.9.14", "description": "A desktop screensaver app using web technologies", "author": "Colin Mitchell (http://muffinlabs.com)", "license": "MIT", @@ -111,6 +111,7 @@ "sass-loader": "^6.0.6", "sinon": "^4.0.2", "spectron": "^3.7.2", + "spectron-fake-dialog": "^0.0.1", "style-loader": "^0.18.2", "url-loader": "^0.5.9", "vue": "^2.5.6", diff --git a/src/lib/savers.js b/src/lib/savers.js index c27bead3..706000a2 100644 --- a/src/lib/savers.js +++ b/src/lib/savers.js @@ -312,7 +312,6 @@ var systemSource = function() { } - /** * set config var k to value v */ @@ -566,11 +565,6 @@ var writeSync = function() { nconf.save(); }; -var getTemplatePath = function() { - var d = systemSource(); - return path.join(d, "__template"); -}; - var getConfig = function(cb) { var configPath = path.join(baseDir, config_file); fs.readFile(configPath, function(err, data) { @@ -596,8 +590,7 @@ var getConfigSync = function() { /** * generate a screensaver template */ -var generateScreensaver = function(opts) { - var src = getTemplatePath(); +var generateScreensaver = function(src, opts) { var destDir = getLocalSource(); var contents = fs.readdirSync(src); diff --git a/src/system-savers/__template/index.html b/src/main/__template/index.html similarity index 100% rename from src/system-savers/__template/index.html rename to src/main/__template/index.html diff --git a/src/system-savers/__template/saver.json b/src/main/__template/saver.json similarity index 100% rename from src/system-savers/__template/saver.json rename to src/main/__template/saver.json diff --git a/src/main/index.js b/src/main/index.js index a7d7dab8..6cd56151 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -613,6 +613,19 @@ var openPrefsOnFirstLoad = function() { }; +var getSystemDir = function() { + if ( process.env.BEFORE_DAWN_SYSTEM_DIR !== undefined ) { + return process.env.BEFORE_DAWN_SYSTEM_DIR; + } + + if ( global.IS_DEV ) { + return __dirname; + } + + return app.getAppPath(); +} + + /** * handle initial startup of app */ @@ -644,9 +657,14 @@ var bootApp = function() { closeRunningScreensavers(); }); + + let saverOpts = { + base: global.basePath, + systemDir: getSystemDir() + }; - log.info("Load config from " + global.basePath); - global.savers.init(global.basePath, function() { + log.info("Load config with", saverOpts); + global.savers.init(saverOpts, function() { configLoaded = true; updateStateManager(); @@ -1215,7 +1233,8 @@ ipcMain.on("set-autostart", (event, value) => { // generate screensaver template with specified attributes // ipcMain.on("generate-screensaver", (event, args) => { - var data = global.savers.generateScreensaver(args); + var src = path.join(getSystemDir(), "__template"); + var data = global.savers.generateScreensaver(src, args); event.sender.send("generate-screensaver", data); global.savers.reset(); diff --git a/src/renderer/Prefs.vue b/src/renderer/Prefs.vue index cbba104c..3691dae3 100644 --- a/src/renderer/Prefs.vue +++ b/src/renderer/Prefs.vue @@ -39,7 +39,9 @@
- +
- +