Skip to content

Commit 49d52e4

Browse files
Merge branch 'hotfix/cli-theme-relative'
2 parents bb6838f + c47dea1 commit 49d52e4

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"url": "https://twitter.com/pascalduez"
2222
}
2323
],
24-
"version": "2.0.4",
24+
"version": "2.0.5",
2525
"license": {
2626
"type": "MIT",
2727
"url": "http://opensource.org/licenses/MIT"

src/cli.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Options:
1010
-h, --help Bring help.
1111
--version Show version.
1212
-v, --verbose Enable verbose mode.
13-
-d, --dest=<dir> Documentation folder [default: sassdoc].
13+
-d, --dest=<dir> Documentation folder.
1414
-c, --config=<path> Path to JSON/YAML configuration file.
1515
-t, --theme=<name> Theme to use.
1616
-p, --parse Parse the input and output JSON data to stdout.
@@ -100,6 +100,7 @@ function ensure(env, options, names) {
100100

101101
if (options[v]) {
102102
env[k] = options[v];
103+
env[k + 'Cwd'] = true;
103104
}
104105
}
105106
}

src/environment.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ export default class Environment extends EventEmitter {
135135
this.dir = process.cwd();
136136
}
137137

138+
if (!this.dest) {
139+
this.dest = 'sassdoc';
140+
}
141+
142+
this.dest = this.resolve(this.dest, this.destCwd);
143+
this.displayDest = path.relative(process.cwd(), this.dest);
144+
138145
if (!this.package) {
139146
this.package = {};
140147
}
@@ -187,7 +194,10 @@ export default class Environment extends EventEmitter {
187194
return this.tryTheme(`sassdoc-theme-${this.theme}`);
188195
}
189196

190-
return this.tryTheme(this.resolve(this.theme));
197+
let theme = this.resolve(this.theme, this.themeCwd);
198+
this.displayTheme = path.relative(process.cwd(), theme);
199+
200+
return this.tryTheme(theme);
191201
}
192202

193203
/**
@@ -289,9 +299,11 @@ export default class Environment extends EventEmitter {
289299
* Resolve given file from `this.dir`.
290300
*
291301
* @param {String} file
302+
* @param {Boolean} cwd - whether it's relative to CWD (like when
303+
* defined in CLI).
292304
* @return {String}
293305
*/
294-
resolve(file) {
295-
return path.resolve(this.dir, file);
306+
resolve(file, cwd = false) {
307+
return path.resolve(cwd ? process.cwd() : this.dir, file);
296308
}
297309
}

src/sassdoc.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default function sassdoc(...args) {
9898
})
9999
.then(() => mkdir(env.dest))
100100
.then(() => {
101-
env.logger.log(`Folder \`${env.dest}\` successfully refreshed.`);
101+
env.logger.log(`Folder \`${env.displayDest}\` successfully refreshed.`);
102102
})
103103
.catch(err => {
104104
// Friendly error for already existing directory.
@@ -120,8 +120,8 @@ export default function sassdoc(...args) {
120120

121121
return promise
122122
.then(() => {
123-
let themeName = env.themeName || 'anonymous';
124-
env.logger.log(`Theme \`${themeName}\` successfully rendered.`);
123+
let displayTheme = env.displayTheme || 'anonymous';
124+
env.logger.log(`Theme \`${displayTheme}\` successfully rendered.`);
125125
});
126126
}
127127

@@ -328,7 +328,6 @@ function srcEnv(documentize, stream) {
328328
env.logger.debug('cwd:', () => process.cwd());
329329

330330
env.src = src;
331-
env.dest = env.dest || 'sassdoc';
332331

333332
env.logger.debug('env:', () => {
334333
let clone = {};

0 commit comments

Comments
 (0)