Skip to content

fix: normalise SASS_PATH #58

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

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,28 @@ function init({ typescript: ts }: { typescript: typeof tsModule }) {
const options: Options = info.config.options || {};
logger.log(`options: ${JSON.stringify(options)}`);

// Set environment variables, resolves #49.
// Load environment variables like SASS_PATH.
// TODO: Add tests for this option.
const dotenvOptions = options.dotenvOptions || {};
if (dotenvOptions) {
dotenvOptions.path = path.resolve(
directory,
dotenvOptions.path || '.env',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about extracting .env into constant?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only used here though, so I think it's OK @lianapache. Certainly if we use it 2+ times, will do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrmckeb Sounds good

);
}
dotenv.config(options.dotenvOptions);

// Normalise SASS_PATH array to absolute paths.
if (process.env.SASS_PATH) {
process.env.SASS_PATH = process.env.SASS_PATH.split(path.delimiter)
.map((sassPath) =>
path.isAbsolute(sassPath)
? sassPath
: path.resolve(directory, sassPath),
)
.join(path.delimiter);
}

// Add postCSS config if enabled.
const postCssOptions = options.postCssOptions || {};

Expand Down