Skip to content

Commit

Permalink
Merge branch 'hotfix/cli-theme-relative'
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriangalliat committed Feb 10, 2015
2 parents bb6838f + c47dea1 commit 49d52e4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"url": "https://twitter.com/pascalduez"
}
],
"version": "2.0.4",
"version": "2.0.5",
"license": {
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
Expand Down
3 changes: 2 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Options:
-h, --help Bring help.
--version Show version.
-v, --verbose Enable verbose mode.
-d, --dest=<dir> Documentation folder [default: sassdoc].
-d, --dest=<dir> Documentation folder.
-c, --config=<path> Path to JSON/YAML configuration file.
-t, --theme=<name> Theme to use.
-p, --parse Parse the input and output JSON data to stdout.
Expand Down Expand Up @@ -100,6 +100,7 @@ function ensure(env, options, names) {

if (options[v]) {
env[k] = options[v];
env[k + 'Cwd'] = true;
}
}
}
18 changes: 15 additions & 3 deletions src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ export default class Environment extends EventEmitter {
this.dir = process.cwd();
}

if (!this.dest) {
this.dest = 'sassdoc';
}

this.dest = this.resolve(this.dest, this.destCwd);
this.displayDest = path.relative(process.cwd(), this.dest);

if (!this.package) {
this.package = {};
}
Expand Down Expand Up @@ -187,7 +194,10 @@ export default class Environment extends EventEmitter {
return this.tryTheme(`sassdoc-theme-${this.theme}`);
}

return this.tryTheme(this.resolve(this.theme));
let theme = this.resolve(this.theme, this.themeCwd);
this.displayTheme = path.relative(process.cwd(), theme);

return this.tryTheme(theme);
}

/**
Expand Down Expand Up @@ -289,9 +299,11 @@ export default class Environment extends EventEmitter {
* Resolve given file from `this.dir`.
*
* @param {String} file
* @param {Boolean} cwd - whether it's relative to CWD (like when
* defined in CLI).
* @return {String}
*/
resolve(file) {
return path.resolve(this.dir, file);
resolve(file, cwd = false) {
return path.resolve(cwd ? process.cwd() : this.dir, file);
}
}
7 changes: 3 additions & 4 deletions src/sassdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function sassdoc(...args) {
})
.then(() => mkdir(env.dest))
.then(() => {
env.logger.log(`Folder \`${env.dest}\` successfully refreshed.`);
env.logger.log(`Folder \`${env.displayDest}\` successfully refreshed.`);
})
.catch(err => {
// Friendly error for already existing directory.
Expand All @@ -120,8 +120,8 @@ export default function sassdoc(...args) {

return promise
.then(() => {
let themeName = env.themeName || 'anonymous';
env.logger.log(`Theme \`${themeName}\` successfully rendered.`);
let displayTheme = env.displayTheme || 'anonymous';
env.logger.log(`Theme \`${displayTheme}\` successfully rendered.`);
});
}

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

env.src = src;
env.dest = env.dest || 'sassdoc';

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

0 comments on commit 49d52e4

Please sign in to comment.