forked from OctoLinker/OctoLinker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
647f409
commit 5348299
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { join } from 'path'; | ||
import pathParse from 'path-parse'; | ||
import { CSS_IMPORT } from '../../packages/helper-grammar-regex-collection/index.js'; | ||
import insertLink from '../insert-link'; | ||
import preset from '../pattern-preset'; | ||
import relativeFile from '../resolver/relative-file.js'; | ||
|
||
export default class Sass { | ||
|
||
static resolve({ path, target }) { | ||
const { dir, name } = pathParse(target); | ||
const prefixedTarget = join(dir, `_${name}`); | ||
|
||
return [ | ||
relativeFile({ path, target: `${prefixedTarget}.scss` }), | ||
relativeFile({ path, target: `${prefixedTarget}.sass` }), | ||
]; | ||
} | ||
|
||
getPattern() { | ||
return preset('sass'); | ||
} | ||
|
||
parseBlob(blob) { | ||
insertLink(blob.el, CSS_IMPORT, { | ||
pluginName: this.constructor.name, | ||
target: '$1', | ||
path: blob.path, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import assert from 'assert'; | ||
import Sass from '../../lib/plugins/sass'; | ||
|
||
describe('Sass', () => { | ||
const path = '/octo/dog.scss'; | ||
|
||
it('resolves link when target does not have a file extension', () => { | ||
assert.deepEqual( | ||
Sass.resolve({ path, target: 'foo' }), | ||
[ | ||
'{BASE_URL}/octo/_foo.scss', | ||
'{BASE_URL}/octo/_foo.sass', | ||
], | ||
); | ||
}); | ||
|
||
it('resolves link when target has a file extension', () => { | ||
assert.deepEqual( | ||
Sass.resolve({ path, target: 'foo.scss' }), | ||
[ | ||
'{BASE_URL}/octo/_foo.scss', | ||
'{BASE_URL}/octo/_foo.sass', | ||
], | ||
); | ||
}); | ||
}); |