From 1085732d42bb59f1c7148e3cb43e88c19e821f93 Mon Sep 17 00:00:00 2001 From: Eric Alli Date: Sat, 15 Jun 2019 13:07:20 -0700 Subject: [PATCH] fix paths in setup script, resolves #10 --- config/site.setup.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/config/site.setup.js b/config/site.setup.js index fd9a446..eeac0e7 100644 --- a/config/site.setup.js +++ b/config/site.setup.js @@ -1,4 +1,5 @@ /* eslint-disable */ +const path = require('path'); const fs = require('fs'); const chalk = require('chalk'); const clear = require('clear'); @@ -8,6 +9,12 @@ const { prompt } = require('enquirer'); const skip_setup = process.env.SKIP_SETUP || false; +let ROOT = process.env.PWD; + +if (!ROOT) { + ROOT = process.cwd(); +} + async function runSetup() { clear(); console.log( @@ -70,7 +77,7 @@ async function runSetup() { data = data.replace(/googleAnalyticsUA: '.*?'/g, `googleAnalyticsUA: '${questions.google_analytics}'`); } - fs.writeFile('./config/site.config.js', data, 'utf8', (err) => { }); + fs.writeFile(path.join(ROOT, '/config/site.config.js'), data, 'utf8', (err) => { }); }); // Add CSS reset to stylesheet @@ -79,7 +86,7 @@ async function runSetup() { '// Load CSS Reset from NPM\n' + '@import "~' + questions.cssreset + '"\n'; - fs.writeFile('./../src/stylesheets/styles.scss', cssContent, (err) => {}); + fs.writeFile(path.join(ROOT, '/src/stylesheets/styles.scss'), cssContent, (err) => {}); } // Add jQuery to scripts @@ -90,7 +97,7 @@ async function runSetup() { + 'window.jQuery = $;\n' + 'window.$ = $;\n'; - fs.writeFile('./../src/javascripts/scripts.js', jsContent, (err) => {}); + fs.writeFile(path.join(ROOT, '/src/javascripts/scripts.js'), jsContent, (err) => {}); } };