-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add --carbon flag to build react-native supernova packages (#749)
- Loading branch information
Showing
2 changed files
with
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
// this plugin will check if there is a corresponding .native file for the input file and output the contents of the native file | ||
// This plugin should be loaded first. | ||
|
||
module.exports = ({ carbon }) => ({ | ||
async load(id) { | ||
if (!carbon) { | ||
return null; | ||
} | ||
if (id) { | ||
const parsed = path.parse(id); | ||
if (parsed) { | ||
if (parsed.name.length > 0) { | ||
const nativeTest = `${parsed.dir}/${parsed.name}.native${parsed.ext}`; | ||
try { | ||
if (fs.existsSync(nativeTest)) { | ||
return fs.readFileSync(nativeTest, { encoding: 'utf8', flag: 'r' }); | ||
} | ||
} catch (err) { | ||
console.log('there was a problem reading the file', nativeTest, err); | ||
} | ||
} | ||
} | ||
} | ||
return null; | ||
}, | ||
}); |