From d4e3b46c3ebf280808ea10ecdde974689e4898ec Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Fri, 3 Nov 2017 03:00:37 +0530 Subject: [PATCH] Fixed bug that didn't allow static server to create symlink --- actions/createStaticServer.js | 9 ++++++--- index.js | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/actions/createStaticServer.js b/actions/createStaticServer.js index c86b7cd..297f6f0 100644 --- a/actions/createStaticServer.js +++ b/actions/createStaticServer.js @@ -2,7 +2,9 @@ var fs = require('fs-extra'); var shell = require('shelljs'); var npath = require('../util/nginxPath'); var conf = require('../util/nginxConf'); +var path = require('path'); +var currentPath = path.normalize(process.cwd()); var { EOL } = require('os'); // \n if used on Linux, \r\n if used on Windows. function createStaticServer(domain, outPort = 80) { @@ -20,10 +22,11 @@ function createStaticServer(domain, outPort = 80) { "}" ) shell.mkdir('-p', npath.enabledSites()); // Creates directory if doesn't exist - shell.rm('-rf', conf(npath.enabledSites(), domain)); + shell.rm('-rf', conf(npath.enabledSites(), domain)); // Removes domain from sites-enabled if exists shell.ln('-sf', conf(npath.availableSites(), domain), conf(npath.enabledSites(), domain)); // Symlink the conf file from sites-available to sites-enabled - shell.rm('-rf', npath.webRoot() + domain); - shell.ln('-sf', "./", npath.webRoot() + domain); // Symlink current directory to nginx's web root + shell.rm('-rf', npath.webRoot() + domain); // Removes domain from webroot if exists + shell.mkdir('-p', npath.webRoot()); // Creating the nginx www path if it doesn't exist so symlink doesn't fail + shell.ln('-sf', currentPath, npath.webRoot() + domain); // Symlink current directory to nginx's web root }; module.exports = createStaticServer; \ No newline at end of file diff --git a/index.js b/index.js index 70a7b94..5a0f17a 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ var createProxyServer = require('./actions/createProxyServer'); var createStaticServer = require('./actions/createStaticServer'); // Check for requirements such as OS version and nginx install. Throw and exit if requirements not found. #Roadmap: Add ability to satisfy any possible requirements. -requirements(); // Comment in development and uncomment this line in production. This should check whether the OS is compatible with this version of `up` +// requirements(); // Comment in development and uncomment this line in production. This should check whether the OS is compatible with this version of `up` program .version('0.0.1') diff --git a/package.json b/package.json index 9e4b8e0..3ace7dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "up-serve", - "version": "0.1.0", + "version": "0.1.0.171103", "description": "A cli tool to quickly create and manage nginx server blocks.", "main": "index.js", "scripts": {