Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
feat(cli): default option creation
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jul 10, 2018
1 parent 4ff68f5 commit 398edb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
#!/usr/bin/env node
import chalk from 'chalk';
import * as commandLineArgs from 'command-line-args';
import { OutputStyle } from './index';
import './verbose';

/**
* Supported output style. Mirrors `style_option_strings[]` in sassc
* (https://github.com/sass/sassc/blob/6a64d0569205bfcf0794a473f97affcb60b22fcc/sassc.c#L184-L189)
*/
enum StyleOption {
SASS_STYLE_COMPRESSED = 'compressed',
SASS_STYLE_COMPACT = 'compact',
SASS_STYLE_EXPANDED = 'expanded',
SASS_STYLE_NESTED = 'nested'
}

const styleOptions = ['nested', 'expanded', 'compact', 'compressed'];
/**
* Definitions of available command line args.
*/
Expand All @@ -22,7 +13,7 @@ const optionDefinitions = [
{
name: 'style',
alias: 't',
description: `Output style. Can be: ${(Object as any).values(StyleOption).join(', ')}.`
description: `Output style. Can be: ${styleOptions.join(', ')}.`
},
{ name: 'line-numbers', alias: 'l', description: 'Emit comments showing original line numbers.' },
{ name: 'load-path', alias: 'I', description: 'Set Sass import path.' },
Expand Down Expand Up @@ -80,4 +71,12 @@ const buildDisplayVersion = async () => {
console.log(usage);
return;
}

const { loadModule } = await import('./loadModule');
const { context } = await loadModule();
const sassOption = context.options.create();
sassOption.outputStyle = OutputStyle.SASS_STYLE_NESTED;
sassOption.precision = 5;

sassOption.dispose();
})();
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { log, enableLogger } from './util/logger';
export { log, enableLogger } from './util/logger';
export { OutputStyle, SassOptionsInterface } from './interop/sassOptions';

0 comments on commit 398edb7

Please sign in to comment.