mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-04 21:09:21 +08:00
Summary: Since jest stopped using node-haste a while ago, we are the only client left. This brings back node-haste back to fbsource to allow us to iterate faster. Reviewed By: bestander Differential Revision: D3641341 fbshipit-source-id: a859f8834765723a3515e2cf265581b9dd83997c
48 lines
888 B
JavaScript
48 lines
888 B
JavaScript
'use strict';
|
|
|
|
const Module = require('./Module');
|
|
const getAssetDataFromName = require('./lib/getAssetDataFromName');
|
|
|
|
class AssetModule extends Module {
|
|
constructor(args, platforms) {
|
|
super(args);
|
|
const { resolution, name, type } = getAssetDataFromName(this.path, platforms);
|
|
this.resolution = resolution;
|
|
this._name = name;
|
|
this._type = type;
|
|
this._dependencies = args.dependencies || [];
|
|
}
|
|
|
|
isHaste() {
|
|
return Promise.resolve(false);
|
|
}
|
|
|
|
getDependencies() {
|
|
return Promise.resolve(this._dependencies);
|
|
}
|
|
|
|
read() {
|
|
return Promise.resolve({});
|
|
}
|
|
|
|
getName() {
|
|
return super.getName().then(
|
|
id => id.replace(/\/[^\/]+$/, `/${this._name}.${this._type}`)
|
|
);
|
|
}
|
|
|
|
hash() {
|
|
return `AssetModule : ${this.path}`;
|
|
}
|
|
|
|
isJSON() {
|
|
return false;
|
|
}
|
|
|
|
isAsset() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
module.exports = AssetModule;
|