From 748af00d55fb77a99587fc61354150cbcab974f7 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa <19631364+k3rn31p4nic@users.noreply.github.com> Date: Mon, 1 Jul 2019 05:10:13 +0530 Subject: [PATCH 1/3] commands(init): support for initing cloned repo --- commands/init.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/commands/init.js b/commands/init.js index 23d01d0..ba7f55e 100644 --- a/commands/init.js +++ b/commands/init.js @@ -1,3 +1,5 @@ +const fs = require("fs"); +const path = require("path"); const shell = require("shelljs"); exports.command = "init"; @@ -35,8 +37,21 @@ exports.handler = function (argv) { shell.cd(".."); // Create symlinks for internal directories - shell.ln("-sf", ".awesome/content/", "content/"); - shell.ln("-sf", ".awesome/static/", "static/"); + let contentDir = path.resolve("content"); + let staticDir = path.resolve("static"); + + if (fs.existsSync(contentDir) && !fs.lstatSync(contentDir).isSymbolicLink()) { + shell.rm("-rf", ".awesome/content"); + shell.ln("-sf", "content/", ".awesome/content/"); + } else { + shell.ln("-sf", ".awesome/content/", "content/"); + } + if (fs.existsSync(staticDir) && !fs.lstatSync(staticDir).isSymbolicLink()) { + shell.rm("-rf", ".awesome/static"); + shell.ln("-sf", "static/", ".awesome/static/"); + } else { + shell.ln("-sf", ".awesome/static/", "static/"); + } shell.echo("Success: Initialized AwesomeDocs"); }; From f78df90d549641f25be2a3698000774737e2bc89 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa <19631364+k3rn31p4nic@users.noreply.github.com> Date: Mon, 1 Jul 2019 05:13:43 +0530 Subject: [PATCH 2/3] version: 2.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f308843..54a8220 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "awesomedocs", - "version": "2.0.0", + "version": "2.0.1", "description": "An awesome documentation site generator!", "main": "index.js", "bin": { From 38f0d025bfd16fe35ccec6afa683bf189ef7a534 Mon Sep 17 00:00:00 2001 From: Sankarsan Kampa <19631364+k3rn31p4nic@users.noreply.github.com> Date: Mon, 1 Jul 2019 05:23:37 +0530 Subject: [PATCH 3/3] commands(init): minor fix --- commands/init.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/init.js b/commands/init.js index ba7f55e..6dd43c4 100644 --- a/commands/init.js +++ b/commands/init.js @@ -42,13 +42,13 @@ exports.handler = function (argv) { if (fs.existsSync(contentDir) && !fs.lstatSync(contentDir).isSymbolicLink()) { shell.rm("-rf", ".awesome/content"); - shell.ln("-sf", "content/", ".awesome/content/"); + shell.ln("-sf", contentDir, ".awesome/content/"); } else { shell.ln("-sf", ".awesome/content/", "content/"); } if (fs.existsSync(staticDir) && !fs.lstatSync(staticDir).isSymbolicLink()) { shell.rm("-rf", ".awesome/static"); - shell.ln("-sf", "static/", ".awesome/static/"); + shell.ln("-sf", staticDir, ".awesome/static/"); } else { shell.ln("-sf", ".awesome/static/", "static/"); }