-
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
f71c2be
commit 4e8c986
Showing
6 changed files
with
133 additions
and
119 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import "partOne"; | ||
import "partTwo"; | ||
import "partThree"; | ||
import 'partOne'; | ||
import 'partTwo'; | ||
import 'partThree'; |
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,28 @@ | ||
module.exports = (function() { | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
return function(importFile) { | ||
return new Promise((resolve, reject) => { | ||
if (!fs.existsSync(importFile)) { | ||
reject('Not a valid file!'); | ||
} else { | ||
const data = fs.readFileSync(importFile); | ||
let imports = []; | ||
|
||
for (const line of data.toString().trim().split('\n')) { | ||
if (!/^import\s["']([a-zA-Z_][a-zA-Z0-9_-]+)["'];?/.test(line)) { | ||
reject('Imports format error!'); | ||
} else { | ||
imports.push(RegExp.$1); | ||
} | ||
} | ||
let result = ''; | ||
for (const elem of imports) { | ||
result += fs.readFileSync(path.resolve(path.dirname(importFile) + '/' + elem) + '.js') + '\n'; | ||
} | ||
resolve(result); | ||
} | ||
}); | ||
}; | ||
})(); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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