Browse Source

Fixed bug that didn't allow static server to create symlink

tags/v0.2.0
Muthu Kumar 7 years ago
parent
commit
d4e3b46c3e
  1. 9
      actions/createStaticServer.js
  2. 2
      index.js
  3. 2
      package.json

9
actions/createStaticServer.js

@ -2,7 +2,9 @@ var fs = require('fs-extra');
var shell = require('shelljs'); var shell = require('shelljs');
var npath = require('../util/nginxPath'); var npath = require('../util/nginxPath');
var conf = require('../util/nginxConf'); 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. var { EOL } = require('os'); // \n if used on Linux, \r\n if used on Windows.
function createStaticServer(domain, outPort = 80) { 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.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.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.rm('-rf', npath.webRoot() + domain); // Removes domain from webroot if exists
shell.ln('-sf', "./", npath.webRoot() + domain); // Symlink current directory to nginx's web root 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; module.exports = createStaticServer;

2
index.js

@ -15,7 +15,7 @@ var createProxyServer = require('./actions/createProxyServer');
var createStaticServer = require('./actions/createStaticServer'); 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. // 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 program
.version('0.0.1') .version('0.0.1')

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "up-serve", "name": "up-serve",
"version": "0.1.0", "version": "0.1.0.171103",
"description": "A cli tool to quickly create and manage nginx server blocks.", "description": "A cli tool to quickly create and manage nginx server blocks.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

Loading…
Cancel
Save