-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* output asset permissions * readme update * update coverage tests * test fixes
- Loading branch information
1 parent
c813b07
commit ae96fbb
Showing
43 changed files
with
334 additions
and
285 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
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,23 +1,31 @@ | ||
const path = require('path'); | ||
const { getOptions } = require('loader-utils'); | ||
const getUniqueAssetName = require('../utils/dedupe-names'); | ||
const sharedlibEmit = require('../utils/sharedlib-emit'); | ||
const getPackageBase = require('../utils/get-package-base'); | ||
const fs = require('fs'); | ||
|
||
module.exports = async function (content) { | ||
if (this.cacheable) | ||
this.cacheable(); | ||
this.async(); | ||
|
||
const id = this.resourcePath; | ||
const options = getOptions(this); | ||
|
||
const pkgBase = getPackageBase(this.resourcePath) || path.dirname(id); | ||
await sharedlibEmit(pkgBase, this.emitFile); | ||
await sharedlibEmit(pkgBase, assetState, this.emitFile); | ||
|
||
const name = getUniqueAssetName(id.substr(pkgBase.length + 1), id, options.assetNames); | ||
const name = getUniqueAssetName(id.substr(pkgBase.length + 1), id, assetState.assetNames); | ||
|
||
const permissions = await new Promise((resolve, reject) => | ||
fs.stat(id, (err, stats) => err ? reject(err) : resolve(stats.mode)) | ||
) | ||
assetState.assetPermissions[name] = permissions; | ||
this.emitFile(name, content); | ||
|
||
this.callback(null, 'module.exports = __non_webpack_require__("./' + name + '")'); | ||
}; | ||
module.exports.raw = true; | ||
let assetState; | ||
module.exports.setAssetState = function (state) { | ||
assetState = state; | ||
} |
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
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
Oops, something went wrong.