-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve output directory #120
Conversation
Codecov Report
@@ Coverage Diff @@
## master #120 +/- ##
==========================================
+ Coverage 97.5% 97.56% +0.06%
==========================================
Files 19 19
Lines 361 370 +9
Branches 64 66 +2
==========================================
+ Hits 352 361 +9
Misses 9 9
Continue to review full report at Codecov.
|
@@ -142,44 +207,45 @@ describe('preval-extract/extractStyles module', () => { | |||
|
|||
expect(fs.writeFileSync).toHaveBeenCalledTimes(1); | |||
expect(fs.writeFileSync.mock.calls[0][0]).toEqual( | |||
path.join(process.cwd(), 'A.css') | |||
path.join(process.cwd(), '.linaria-cache/filename.css') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if we should display a warning, if the filename
is used without single
?
); | ||
expect(fs.writeFileSync.mock.calls[1][1]).toMatch( | ||
'.classname{color: #ffffff}\n.other{color: #000000}' | ||
); | ||
}); | ||
|
||
it('should overwrite if the file has changed', () => { | ||
it('should overwrite if the tyles has changed', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: styles
: filename; | ||
} | ||
|
||
export function makeAbsolute(filename: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but shouldn't path.resolve(filename)
solve this?
cache: true, | ||
extract: true, | ||
single: false, | ||
outDir: '.linaria-cache', | ||
filename: 'styles.css', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we shift those defaults to function arguments?
export default function extractStyles(
types: BabelTypes,
program: NodePath<*>,
currentFilename: string,
options: {
single?: boolean = false,
filename?: string = 'styles.css',
outDir?: string = '.linaria-cache',
cache?: boolean = true,
extract?: boolean = true,
}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we cannot.
The snippet you posted is invalid:
options: {
single?: boolean = false,
filename?: string = 'styles.css',
outDir?: string = '.linaria-cache',
cache?: boolean = true,
extract?: boolean = true,
}
Invalid syntax.
And besides:
function test(opts = { test: true }) { console.log(opts); }
test() // => { test: true }
test({ what: 'ever' }) // => { what: 'ever' }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I think we could replace most of path.join(process.cwd(), name)
with path.resolve(name)
.
Documentation says:
If after processing all given path segments an absolute path has not yet been generated, the current working directory is used.
Closes #101