fossbook 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/fossbook.js CHANGED
@@ -14,7 +14,7 @@ Commands:
14
14
  build Build the static site
15
15
  serve Build and start a local dev server
16
16
  new <title> Create a new post
17
- init Create a new fossbook site project
17
+ init [name] Create a new fossbook site project
18
18
  deploy Build, commit, push, and monitor deployment
19
19
 
20
20
  Options:
@@ -97,7 +97,8 @@ switch (command) {
97
97
 
98
98
  case "init": {
99
99
  const { initProject } = require("../lib/init");
100
- initProject({ github: hasFlag("--github") });
100
+ const projectName = !args[1] || args[1].startsWith("--") ? null : args[1];
101
+ initProject({ github: hasFlag("--github"), name: projectName });
101
102
  break;
102
103
  }
103
104
 
package/lib/init.js CHANGED
@@ -52,7 +52,19 @@ jobs:
52
52
  `;
53
53
 
54
54
  function initProject(options = {}) {
55
- const cwd = process.cwd();
55
+ let cwd = process.cwd();
56
+
57
+ // If a project name is given, create the directory and work inside it
58
+ if (options.name) {
59
+ const projectDir = path.join(cwd, options.name);
60
+ if (fs.existsSync(projectDir)) {
61
+ console.error(`Error: Directory "${options.name}" already exists.`);
62
+ process.exit(1);
63
+ }
64
+ fs.mkdirSync(projectDir, { recursive: true });
65
+ cwd = projectDir;
66
+ console.log(`Creating new site in ${cwd}\n`);
67
+ }
56
68
 
57
69
  // Create directories
58
70
  const dirs = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fossbook",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A lightweight static blog site generator for GitHub Pages",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {