Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 21ef77a

Browse files
authored
Allow parsing .cjs files as javascript (#13)
1 parent 0b6b738 commit 21ef77a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.tape.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ module.exports = {
6161
expect: 'basic.import.expect.css',
6262
result: 'basic.import.result.css'
6363
},
64+
'basic:import-cjs': {
65+
message: 'supports { importFrom: "test/import-variables.cjs" } usage',
66+
options: {
67+
importFrom: 'test/import-variables.cjs'
68+
},
69+
expect: 'basic.import.expect.css',
70+
result: 'basic.import.result.css'
71+
},
6472
'basic:import-js-from': {
6573
message: 'supports { importFrom: { from: "test/import-variables.js" } } usage',
6674
options: {

src/lib/import-from.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default function importEnvironmentVariablesFromSources(sources) {
7373
}).reduce(async (environmentVariables, source) => {
7474
const { type, from } = await source;
7575

76-
if (type === 'js') {
76+
if (type === 'js' || type === 'cjs') {
7777
return Object.assign(environmentVariables, await importEnvironmentVariablesFromJSFile(from));
7878
}
7979

test/import-variables.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
environmentVariables: {
3+
'--some-custom-padding': '20px',
4+
'--another-custom-width': '600px'
5+
}
6+
};

0 commit comments

Comments
 (0)