- [react-packager] Switch from Q to Bluebird as promises library | Pilwon Huh
- [Touchable] Change default `activeOpacity` to 0.2 to match iOS | James Ide - [ReactNative] Normalize name for examples | Christopher Chedeau - [ReactNative] Added support for 3 digit hex colors | Arthur Lee - [react-packager] Fix EISDIR error | Amjad Masad - make renderError and renderLoading props optional for WebView | Don Yu
This commit is contained in:
Родитель
b66710c6ed
Коммит
2cced4b940
|
@ -11,7 +11,6 @@
|
||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* @providesModule ListViewPagingExample
|
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
diff a/Libraries/FBReactKit/js/react-native-github/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Libraries/FBReactKit/js/react-native-github/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj (rejected hunks)
|
|
||||||
@@ -19,6 +19,7 @@
|
|
||||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
|
||||||
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
|
||||||
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; };
|
|
||||||
+ D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; };
|
|
||||||
/* End PBXBuildFile section */
|
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
|
||||||
@@ -78,6 +79,13 @@
|
|
||||||
remoteGlobalIDString = 134814201AA4EA6300B7C361;
|
|
||||||
remoteInfo = RCTActionSheet;
|
|
||||||
};
|
|
||||||
+ D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */ = {
|
|
||||||
+ isa = PBXContainerItemProxy;
|
|
||||||
+ containerPortal = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
|
|
||||||
+ proxyType = 2;
|
|
||||||
+ remoteGlobalIDString = 832C81801AAF6DEF007FA2F7;
|
|
||||||
+ remoteInfo = RCTVibration;
|
|
||||||
+ };
|
|
||||||
/* End PBXContainerItemProxy section */
|
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
|
||||||
@@ -98,6 +106,7 @@
|
|
||||||
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
|
||||||
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
|
||||||
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../../Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
|
|
||||||
+ D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../../Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
|
||||||
@@ -112,6 +121,7 @@
|
|
||||||
isa = PBXFrameworksBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
+ D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */,
|
|
||||||
147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */,
|
|
||||||
134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */,
|
|
||||||
134A8A2A1AACED7A00945AAE /* libRCTGeolocation.a in Frameworks */,
|
|
||||||
@@ -145,6 +155,7 @@
|
|
||||||
1316A21D1AA397F400C0188E /* Libraries */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
+ D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */,
|
|
||||||
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */,
|
|
||||||
13417FFA1AA91531003F314A /* ReactKit.xcodeproj */,
|
|
||||||
134454551AAFCAAE003F0779 /* RCTAdSupport.xcodeproj */,
|
|
||||||
@@ -334,6 +353,10 @@
|
|
||||||
ProjectRef = 13417FEA1AA914B8003F314A /* RCTText.xcodeproj */;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
+ ProductGroup = D85B82921AB6D5CE003F4FE2 /* Products */;
|
|
||||||
+ ProjectRef = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
|
|
||||||
+ },
|
|
||||||
+ {
|
|
||||||
ProductGroup = 13417FFB1AA91531003F314A /* Products */;
|
|
||||||
ProjectRef = 13417FFA1AA91531003F314A /* ReactKit.xcodeproj */;
|
|
||||||
},
|
|
||||||
@@ -396,6 +419,13 @@
|
|
||||||
remoteRef = 147CED4A1AB34F8C00DA3E4C /* PBXContainerItemProxy */;
|
|
||||||
sourceTree = BUILT_PRODUCTS_DIR;
|
|
||||||
};
|
|
||||||
+ D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */ = {
|
|
||||||
+ isa = PBXReferenceProxy;
|
|
||||||
+ fileType = archive.ar;
|
|
||||||
+ path = libRCTVibration.a;
|
|
||||||
+ remoteRef = D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */;
|
|
||||||
+ sourceTree = BUILT_PRODUCTS_DIR;
|
|
||||||
+ };
|
|
||||||
/* End PBXReferenceProxy section */
|
|
||||||
|
|
||||||
/* Begin PBXResourcesBuildPhase section */
|
|
|
@ -33,19 +33,19 @@ var { TestModule } = React.addons;
|
||||||
var createExamplePage = require('./createExamplePage');
|
var createExamplePage = require('./createExamplePage');
|
||||||
|
|
||||||
var COMPONENTS = [
|
var COMPONENTS = [
|
||||||
require('./ActivityIndicatorExample'),
|
require('./ActivityIndicatorIOSExample'),
|
||||||
require('./DatePickerExample'),
|
require('./DatePickerIOSExample'),
|
||||||
require('./ImageExample'),
|
require('./ImageExample'),
|
||||||
|
require('./ListViewExample'),
|
||||||
require('./ListViewPagingExample'),
|
require('./ListViewPagingExample'),
|
||||||
require('./ListViewSimpleExample'),
|
|
||||||
require('./MapViewExample'),
|
require('./MapViewExample'),
|
||||||
require('./NavigatorIOSExample'),
|
require('./NavigatorIOSExample'),
|
||||||
NavigatorExample,
|
NavigatorExample,
|
||||||
require('./PickerExample'),
|
require('./PickerIOSExample'),
|
||||||
require('./ScrollViewExample'),
|
require('./ScrollViewExample'),
|
||||||
require('./SliderIOSExample'),
|
require('./SliderIOSExample'),
|
||||||
require('./SwitchExample'),
|
require('./SwitchIOSExample'),
|
||||||
require('./TabBarExample'),
|
require('./TabBarIOSExample'),
|
||||||
require('./TextExample.ios'),
|
require('./TextExample.ios'),
|
||||||
require('./TextInputExample'),
|
require('./TextInputExample'),
|
||||||
require('./TouchableExample'),
|
require('./TouchableExample'),
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
var StyleSheet = require('StyleSheet');
|
var StyleSheet = require('StyleSheet');
|
||||||
var {
|
var {
|
||||||
ActivityIndicatorIOS,
|
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
@ -95,8 +94,6 @@ var WebViewExample = React.createClass({
|
||||||
automaticallyAdjustContentInsets={false}
|
automaticallyAdjustContentInsets={false}
|
||||||
style={styles.webView}
|
style={styles.webView}
|
||||||
url={this.state.url}
|
url={this.state.url}
|
||||||
renderError={this.renderError}
|
|
||||||
renderLoading={this.renderLoading}
|
|
||||||
onNavigationStateChange={this.onNavigationStateChange}
|
onNavigationStateChange={this.onNavigationStateChange}
|
||||||
startInLoadingState={true}
|
startInLoadingState={true}
|
||||||
/>
|
/>
|
||||||
|
@ -129,33 +126,6 @@ var WebViewExample = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderError: function(errorDomain, errorCode, errorDesc) {
|
|
||||||
return (
|
|
||||||
<View style={styles.errorContainer}>
|
|
||||||
<Text style={styles.errorTextTitle}>
|
|
||||||
Error loading page
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.errorText}>
|
|
||||||
{'Domain: ' + errorDomain}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.errorText}>
|
|
||||||
{'Error Code: ' + errorCode}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.errorText}>
|
|
||||||
{'Description: ' + errorDesc}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderLoading: function() {
|
|
||||||
return (
|
|
||||||
<View style={styles.loadingView}>
|
|
||||||
<ActivityIndicatorIOS />
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
onSubmitEditing: function(event) {
|
onSubmitEditing: function(event) {
|
||||||
this.pressGoButton();
|
this.pressGoButton();
|
||||||
},
|
},
|
||||||
|
@ -230,28 +200,6 @@ var styles = StyleSheet.create({
|
||||||
borderRadius: 3,
|
borderRadius: 3,
|
||||||
alignSelf: 'stretch',
|
alignSelf: 'stretch',
|
||||||
},
|
},
|
||||||
loadingView: {
|
|
||||||
backgroundColor: BGWASH,
|
|
||||||
flex: 1,
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
errorContainer: {
|
|
||||||
flex: 1,
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: BGWASH,
|
|
||||||
},
|
|
||||||
errorTextTitle: {
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: '500',
|
|
||||||
marginBottom: 10,
|
|
||||||
},
|
|
||||||
errorText: {
|
|
||||||
fontSize: 14,
|
|
||||||
textAlign: 'center',
|
|
||||||
marginBottom: 2,
|
|
||||||
},
|
|
||||||
statusBar: {
|
statusBar: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</BuildActionEntry>
|
</BuildActionEntry>
|
||||||
<BuildActionEntry
|
<BuildActionEntry
|
||||||
buildForTesting = "YES"
|
buildForTesting = "YES"
|
||||||
buildForRunning = "YES"
|
buildForRunning = "NO"
|
||||||
buildForProfiling = "NO"
|
buildForProfiling = "NO"
|
||||||
buildForArchiving = "NO"
|
buildForArchiving = "NO"
|
||||||
buildForAnalyzing = "YES">
|
buildForAnalyzing = "YES">
|
||||||
|
|
|
@ -59,7 +59,7 @@ var TouchableOpacity = React.createClass({
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
activeOpacity: 0.5,
|
activeOpacity: 0.2,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var ActivityIndicatorIOS = require('ActivityIndicatorIOS');
|
||||||
var EdgeInsetsPropType = require('EdgeInsetsPropType');
|
var EdgeInsetsPropType = require('EdgeInsetsPropType');
|
||||||
var React = require('React');
|
var React = require('React');
|
||||||
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
|
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
|
||||||
var StyleSheet = require('StyleSheet');
|
var StyleSheet = require('StyleSheet');
|
||||||
|
var Text = require('Text');
|
||||||
var View = require('View');
|
var View = require('View');
|
||||||
|
|
||||||
var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');
|
var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');
|
||||||
|
@ -27,6 +29,7 @@ var RCTWebViewManager = require('NativeModules').WebViewManager;
|
||||||
|
|
||||||
var invariant = require('invariant');
|
var invariant = require('invariant');
|
||||||
|
|
||||||
|
var BGWASH = 'rgba(255,255,255,0.8)';
|
||||||
var RCT_WEBVIEW_REF = 'webview';
|
var RCT_WEBVIEW_REF = 'webview';
|
||||||
|
|
||||||
var WebViewState = keyMirror({
|
var WebViewState = keyMirror({
|
||||||
|
@ -52,16 +55,38 @@ type ErrorEvent = {
|
||||||
|
|
||||||
type Event = Object;
|
type Event = Object;
|
||||||
|
|
||||||
|
var defaultRenderLoading = () => (
|
||||||
|
<View style={styles.loadingView}>
|
||||||
|
<ActivityIndicatorIOS />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
var defaultRenderError = (errorDomain, errorCode, errorDesc) => (
|
||||||
|
<View style={styles.errorContainer}>
|
||||||
|
<Text style={styles.errorTextTitle}>
|
||||||
|
Error loading page
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.errorText}>
|
||||||
|
{'Domain: ' + errorDomain}
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.errorText}>
|
||||||
|
{'Error Code: ' + errorCode}
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.errorText}>
|
||||||
|
{'Description: ' + errorDesc}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
var WebView = React.createClass({
|
var WebView = React.createClass({
|
||||||
statics: {
|
statics: {
|
||||||
NavigationType: NavigationType,
|
NavigationType: NavigationType,
|
||||||
},
|
},
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
renderError: PropTypes.func.isRequired, // view to show if there's an error
|
|
||||||
renderLoading: PropTypes.func.isRequired, // loading indicator to show
|
|
||||||
url: PropTypes.string,
|
url: PropTypes.string,
|
||||||
html: PropTypes.string,
|
html: PropTypes.string,
|
||||||
|
renderError: PropTypes.func, // view to show if there's an error
|
||||||
|
renderLoading: PropTypes.func, // loading indicator to show
|
||||||
automaticallyAdjustContentInsets: PropTypes.bool,
|
automaticallyAdjustContentInsets: PropTypes.bool,
|
||||||
shouldInjectAJAXHandler: PropTypes.bool,
|
shouldInjectAJAXHandler: PropTypes.bool,
|
||||||
contentInset: EdgeInsetsPropType,
|
contentInset: EdgeInsetsPropType,
|
||||||
|
@ -87,20 +112,23 @@ var WebView = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
var otherView = null;
|
var otherView = null;
|
||||||
|
|
||||||
if (this.state.viewState === WebViewState.LOADING) {
|
if (this.state.viewState === WebViewState.LOADING) {
|
||||||
otherView = this.props.renderLoading();
|
otherView = (this.props.renderLoading || defaultRenderLoading)();
|
||||||
} else if (this.state.viewState === WebViewState.ERROR) {
|
} else if (this.state.viewState === WebViewState.ERROR) {
|
||||||
var errorEvent = this.state.lastErrorEvent;
|
var errorEvent = this.state.lastErrorEvent;
|
||||||
invariant(
|
invariant(
|
||||||
errorEvent != null,
|
errorEvent != null,
|
||||||
'lastErrorEvent expected to be non-null'
|
'lastErrorEvent expected to be non-null'
|
||||||
);
|
);
|
||||||
otherView = this.props.renderError(
|
otherView = (this.props.renderError || defaultRenderError)(
|
||||||
errorEvent.domain,
|
errorEvent.domain,
|
||||||
errorEvent.code,
|
errorEvent.code,
|
||||||
errorEvent.description);
|
errorEvent.description
|
||||||
|
);
|
||||||
} else if (this.state.viewState !== WebViewState.IDLE) {
|
} else if (this.state.viewState !== WebViewState.IDLE) {
|
||||||
console.error('RCTWebView invalid state encountered: ' + this.state.loading);
|
console.error(
|
||||||
|
'RCTWebView invalid state encountered: ' + this.state.loading
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var webViewStyles = [styles.container, this.props.style];
|
var webViewStyles = [styles.container, this.props.style];
|
||||||
|
@ -196,10 +224,32 @@ var styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
|
errorContainer: {
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
backgroundColor: BGWASH,
|
||||||
|
},
|
||||||
|
errorText: {
|
||||||
|
fontSize: 14,
|
||||||
|
textAlign: 'center',
|
||||||
|
marginBottom: 2,
|
||||||
|
},
|
||||||
|
errorTextTitle: {
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: '500',
|
||||||
|
marginBottom: 10,
|
||||||
|
},
|
||||||
hidden: {
|
hidden: {
|
||||||
height: 0,
|
height: 0,
|
||||||
flex: 0, // disable 'flex:1' when hiding a View
|
flex: 0, // disable 'flex:1' when hiding a View
|
||||||
},
|
},
|
||||||
|
loadingView: {
|
||||||
|
backgroundColor: BGWASH,
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = WebView;
|
module.exports = WebView;
|
||||||
|
|
|
@ -459,7 +459,17 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[
|
||||||
NSUInteger blue = -1;
|
NSUInteger blue = -1;
|
||||||
CGFloat alpha = 1.0;
|
CGFloat alpha = 1.0;
|
||||||
if ([colorString hasPrefix:@"#"]) {
|
if ([colorString hasPrefix:@"#"]) {
|
||||||
sscanf([colorString UTF8String], "#%02tX%02tX%02tX", &red, &green, &blue);
|
if (colorString.length == 4) { // 3 digit hex
|
||||||
|
sscanf([colorString UTF8String], "#%01tX%01tX%01tX", &red, &green, &blue);
|
||||||
|
// expand to 6 digit hex
|
||||||
|
red = red | (red << 4);
|
||||||
|
green = green | (green << 4);
|
||||||
|
blue = blue | (blue << 4);
|
||||||
|
} else if (colorString.length == 7) { // normal 6 digit hex
|
||||||
|
sscanf([colorString UTF8String], "#%02tX%02tX%02tX", &red, &green, &blue);
|
||||||
|
} else {
|
||||||
|
RCTLogError(@"Invalid hex color %@. Hex colors should be 3 or 6 digits long", colorString);
|
||||||
|
}
|
||||||
} else if ([colorString hasPrefix:@"rgba("]) {
|
} else if ([colorString hasPrefix:@"rgba("]) {
|
||||||
double tmpAlpha;
|
double tmpAlpha;
|
||||||
sscanf([colorString UTF8String], "rgba(%zd,%zd,%zd,%lf)", &red, &green, &blue, &tmpAlpha);
|
sscanf([colorString UTF8String], "rgba(%zd,%zd,%zd,%lf)", &red, &green, &blue, &tmpAlpha);
|
||||||
|
|
|
@ -53,13 +53,13 @@
|
||||||
"joi": "~5.1.0",
|
"joi": "~5.1.0",
|
||||||
"module-deps": "3.5.6",
|
"module-deps": "3.5.6",
|
||||||
"optimist": "0.6.1",
|
"optimist": "0.6.1",
|
||||||
"q": "1.0.1",
|
|
||||||
"sane": "1.0.1",
|
"sane": "1.0.1",
|
||||||
"uglify-js": "~2.4.16",
|
"uglify-js": "~2.4.16",
|
||||||
"underscore": "1.7.0",
|
"underscore": "1.7.0",
|
||||||
"worker-farm": "1.1.0",
|
"worker-farm": "1.1.0",
|
||||||
"yargs": "1.3.2",
|
"yargs": "1.3.2",
|
||||||
"ws": "0.4.31"
|
"ws": "0.4.31",
|
||||||
|
"bluebird": "^2.9.21"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest-cli": "0.2.1",
|
"jest-cli": "0.2.1",
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
jest.autoMockOff();
|
||||||
|
module.exports = require.requireActual('bluebird');
|
||||||
|
jest.autoMockOn();
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('../index')
|
.dontMock('../index')
|
||||||
.dontMock('q')
|
|
||||||
.dontMock('path')
|
.dontMock('path')
|
||||||
.dontMock('absolute-path')
|
.dontMock('absolute-path')
|
||||||
.dontMock('../docblock')
|
.dontMock('../docblock')
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ModuleDescriptor = require('../../ModuleDescriptor');
|
var ModuleDescriptor = require('../../ModuleDescriptor');
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var docblock = require('./docblock');
|
var docblock = require('./docblock');
|
||||||
var requirePattern = require('../requirePattern');
|
var requirePattern = require('../requirePattern');
|
||||||
|
@ -19,10 +19,10 @@ var debug = require('debug')('DependecyGraph');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var declareOpts = require('../../../lib/declareOpts');
|
var declareOpts = require('../../../lib/declareOpts');
|
||||||
|
|
||||||
var readFile = q.nfbind(fs.readFile);
|
var readFile = Promise.promisify(fs.readFile);
|
||||||
var readDir = q.nfbind(fs.readdir);
|
var readDir = Promise.promisify(fs.readdir);
|
||||||
var lstat = q.nfbind(fs.lstat);
|
var lstat = Promise.promisify(fs.lstat);
|
||||||
var realpath = q.nfbind(fs.realpath);
|
var realpath = Promise.promisify(fs.realpath);
|
||||||
|
|
||||||
var validateOpts = declareOpts({
|
var validateOpts = declareOpts({
|
||||||
roots: {
|
roots: {
|
||||||
|
@ -73,7 +73,7 @@ DependecyGraph.prototype.load = function() {
|
||||||
return this._loading;
|
return this._loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._loading = q.all([
|
this._loading = Promise.all([
|
||||||
this._search(),
|
this._search(),
|
||||||
this._buildAssetMap(),
|
this._buildAssetMap(),
|
||||||
]);
|
]);
|
||||||
|
@ -263,7 +263,7 @@ DependecyGraph.prototype._search = function() {
|
||||||
var dir = this._queue.shift();
|
var dir = this._queue.shift();
|
||||||
|
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
return q.Promise.resolve(this._graph);
|
return Promise.resolve(this._graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steps:
|
// Steps:
|
||||||
|
@ -292,10 +292,10 @@ DependecyGraph.prototype._search = function() {
|
||||||
|
|
||||||
var processing = self._findAndProcessPackage(files, dir)
|
var processing = self._findAndProcessPackage(files, dir)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
return q.all(modulePaths.map(self._processModule.bind(self)));
|
return Promise.all(modulePaths.map(self._processModule.bind(self)));
|
||||||
});
|
});
|
||||||
|
|
||||||
return q.all([
|
return Promise.all([
|
||||||
processing,
|
processing,
|
||||||
self._search()
|
self._search()
|
||||||
]);
|
]);
|
||||||
|
@ -324,7 +324,7 @@ DependecyGraph.prototype._findAndProcessPackage = function(files, root) {
|
||||||
if (packagePath != null) {
|
if (packagePath != null) {
|
||||||
return this._processPackage(packagePath);
|
return this._processPackage(packagePath);
|
||||||
} else {
|
} else {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ DependecyGraph.prototype._processPackage = function(packagePath) {
|
||||||
packageJson = JSON.parse(content);
|
packageJson = JSON.parse(content);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debug('WARNING: malformed package.json: ', packagePath);
|
debug('WARNING: malformed package.json: ', packagePath);
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageJson.name == null) {
|
if (packageJson.name == null) {
|
||||||
|
@ -346,7 +346,7 @@ DependecyGraph.prototype._processPackage = function(packagePath) {
|
||||||
'WARNING: package.json `%s` is missing a name field',
|
'WARNING: package.json `%s` is missing a name field',
|
||||||
packagePath
|
packagePath
|
||||||
);
|
);
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
packageJson._root = packageRoot;
|
packageJson._root = packageRoot;
|
||||||
|
@ -556,7 +556,7 @@ DependecyGraph.prototype._getAbsolutePath = function(filePath) {
|
||||||
|
|
||||||
DependecyGraph.prototype._buildAssetMap = function() {
|
DependecyGraph.prototype._buildAssetMap = function() {
|
||||||
if (this._assetRoots == null || this._assetRoots.length === 0) {
|
if (this._assetRoots == null || this._assetRoots.length === 0) {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._assetMap = Object.create(null);
|
this._assetMap = Object.create(null);
|
||||||
|
@ -640,13 +640,13 @@ function withExtJs(file) {
|
||||||
|
|
||||||
function handleBrokenLink(e) {
|
function handleBrokenLink(e) {
|
||||||
debug('WARNING: error stating, possibly broken symlink', e.message);
|
debug('WARNING: error stating, possibly broken symlink', e.message);
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
function readAndStatDir(dir) {
|
function readAndStatDir(dir) {
|
||||||
return readDir(dir)
|
return readDir(dir)
|
||||||
.then(function(files){
|
.then(function(files){
|
||||||
return q.all(files.map(function(filePath) {
|
return Promise.all(files.map(function(filePath) {
|
||||||
return realpath(path.join(dir, filePath)).catch(handleBrokenLink);
|
return realpath(path.join(dir, filePath)).catch(handleBrokenLink);
|
||||||
}));
|
}));
|
||||||
}).then(function(files) {
|
}).then(function(files) {
|
||||||
|
@ -660,7 +660,7 @@ function readAndStatDir(dir) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
files,
|
files,
|
||||||
q.all(stats),
|
Promise.all(stats),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -676,7 +676,7 @@ function buildAssetMap(roots, processAsset) {
|
||||||
var root = queue.shift();
|
var root = queue.shift();
|
||||||
|
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return readAndStatDir(root).spread(function(files, stats) {
|
return readAndStatDir(root).spread(function(files, stats) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ jest.dontMock('../')
|
||||||
.dontMock('../requirePattern')
|
.dontMock('../requirePattern')
|
||||||
.setMock('../../ModuleDescriptor', function(data) {return data;});
|
.setMock('../../ModuleDescriptor', function(data) {return data;});
|
||||||
|
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
|
|
||||||
describe('HasteDependencyResolver', function() {
|
describe('HasteDependencyResolver', function() {
|
||||||
var HasteDependencyResolver;
|
var HasteDependencyResolver;
|
||||||
|
@ -41,7 +41,7 @@ describe('HasteDependencyResolver', function() {
|
||||||
return deps;
|
return deps;
|
||||||
});
|
});
|
||||||
depGraph.load.mockImpl(function() {
|
depGraph.load.mockImpl(function() {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
return depResolver.getDependencies('/root/index.js', { dev: false })
|
return depResolver.getDependencies('/root/index.js', { dev: false })
|
||||||
|
@ -101,7 +101,7 @@ describe('HasteDependencyResolver', function() {
|
||||||
return deps;
|
return deps;
|
||||||
});
|
});
|
||||||
depGraph.load.mockImpl(function() {
|
depGraph.load.mockImpl(function() {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
return depResolver.getDependencies('/root/index.js', { dev: true })
|
return depResolver.getDependencies('/root/index.js', { dev: true })
|
||||||
|
@ -162,7 +162,7 @@ describe('HasteDependencyResolver', function() {
|
||||||
return deps;
|
return deps;
|
||||||
});
|
});
|
||||||
depGraph.load.mockImpl(function() {
|
depGraph.load.mockImpl(function() {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
return depResolver.getDependencies('/root/index.js', { dev: false })
|
return depResolver.getDependencies('/root/index.js', { dev: false })
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Promise = require('q').Promise;
|
var Promise = require('bluebird');
|
||||||
var ModuleDescriptor = require('../ModuleDescriptor');
|
var ModuleDescriptor = require('../ModuleDescriptor');
|
||||||
|
|
||||||
var mdeps = require('module-deps');
|
var mdeps = require('module-deps');
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
|
.dontMock('util')
|
||||||
|
.dontMock('events')
|
||||||
.dontMock('../')
|
.dontMock('../')
|
||||||
.dontMock('q')
|
.dontMock('q')
|
||||||
.setMock(
|
.setMock(
|
||||||
|
@ -38,6 +40,21 @@ describe('FileWatcher', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pit('should emit events', function() {
|
||||||
|
var cb;
|
||||||
|
Watcher.prototype.on.mockImplementation(function(type, callback) {
|
||||||
|
cb = callback;
|
||||||
|
});
|
||||||
|
var fileWatcher = new FileWatcher(['rootDir']);
|
||||||
|
var handler = jest.genMockFn();
|
||||||
|
fileWatcher.on('all', handler);
|
||||||
|
return fileWatcher._loading.then(function(){
|
||||||
|
cb(1, 2, 3, 4);
|
||||||
|
jest.runAllTimers();
|
||||||
|
expect(handler.mock.calls[0]).toEqual([1, 2, 3, 4]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
pit('it should end the watcher', function() {
|
pit('it should end the watcher', function() {
|
||||||
var fileWatcher = new FileWatcher(['rootDir']);
|
var fileWatcher = new FileWatcher(['rootDir']);
|
||||||
Watcher.prototype.close.mockImplementation(function(callback) {
|
Watcher.prototype.close.mockImplementation(function(callback) {
|
||||||
|
|
|
@ -10,12 +10,10 @@
|
||||||
|
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var sane = require('sane');
|
var sane = require('sane');
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
|
|
||||||
var Promise = q.Promise;
|
|
||||||
|
|
||||||
var detectingWatcherClass = new Promise(function(resolve) {
|
var detectingWatcherClass = new Promise(function(resolve) {
|
||||||
exec('which watchman', function(err, out) {
|
exec('which watchman', function(err, out) {
|
||||||
if (err || out.length === 0) {
|
if (err || out.length === 0) {
|
||||||
|
@ -41,12 +39,12 @@ function FileWatcher(rootConfigs) {
|
||||||
|
|
||||||
fileWatcher = this;
|
fileWatcher = this;
|
||||||
|
|
||||||
this._loading = q.all(
|
this._loading = Promise.all(
|
||||||
rootConfigs.map(createWatcher)
|
rootConfigs.map(createWatcher)
|
||||||
).then(function(watchers) {
|
).then(function(watchers) {
|
||||||
watchers.forEach(function(watcher) {
|
watchers.forEach(function(watcher) {
|
||||||
watcher.on('all', function(type, filepath, root) {
|
watcher.on('all', function(type, filepath, root, stat) {
|
||||||
fileWatcher.emit('all', type, filepath, root);
|
fileWatcher.emit('all', type, filepath, root, stat);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return watchers;
|
return watchers;
|
||||||
|
@ -59,7 +57,7 @@ util.inherits(FileWatcher, EventEmitter);
|
||||||
FileWatcher.prototype.end = function() {
|
FileWatcher.prototype.end = function() {
|
||||||
return this._loading.then(function(watchers) {
|
return this._loading.then(function(watchers) {
|
||||||
watchers.forEach(function(watcher) {
|
watchers.forEach(function(watcher) {
|
||||||
return q.ninvoke(watcher, 'close');
|
return Promise.promisify(watcher.close, watcher)();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -88,7 +86,7 @@ function createWatcher(rootConfig) {
|
||||||
FileWatcher.createDummyWatcher = function() {
|
FileWatcher.createDummyWatcher = function() {
|
||||||
var ev = new EventEmitter();
|
var ev = new EventEmitter();
|
||||||
ev.end = function() {
|
ev.end = function() {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
return ev;
|
return ev;
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,12 +14,10 @@ var declareOpts = require('../lib/declareOpts');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var isAbsolutePath = require('absolute-path');
|
var isAbsolutePath = require('absolute-path');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
var tmpdir = require('os').tmpDir();
|
var tmpdir = require('os').tmpDir();
|
||||||
var version = require('../../../../package.json').version;
|
var version = require('../../../../package.json').version;
|
||||||
|
|
||||||
var Promise = q.Promise;
|
|
||||||
|
|
||||||
var validateOpts = declareOpts({
|
var validateOpts = declareOpts({
|
||||||
resetCache: {
|
resetCache: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -74,7 +72,7 @@ Cache.prototype._set = function(filepath, loaderPromise) {
|
||||||
this._data[filepath] = loaderPromise.then(function(data) {
|
this._data[filepath] = loaderPromise.then(function(data) {
|
||||||
return [
|
return [
|
||||||
data,
|
data,
|
||||||
q.nfbind(fs.stat)(filepath)
|
Promise.promisify(fs.stat)(filepath)
|
||||||
];
|
];
|
||||||
}).spread(function(data, stat) {
|
}).spread(function(data, stat) {
|
||||||
this._persistEventually();
|
this._persistEventually();
|
||||||
|
@ -105,13 +103,13 @@ Cache.prototype._persistCache = function() {
|
||||||
var data = this._data;
|
var data = this._data;
|
||||||
var cacheFilepath = this._cacheFilePath;
|
var cacheFilepath = this._cacheFilePath;
|
||||||
|
|
||||||
this._persisting = q.all(_.values(data))
|
this._persisting = Promise.all(_.values(data))
|
||||||
.then(function(values) {
|
.then(function(values) {
|
||||||
var json = Object.create(null);
|
var json = Object.create(null);
|
||||||
Object.keys(data).forEach(function(key, i) {
|
Object.keys(data).forEach(function(key, i) {
|
||||||
json[key] = values[i];
|
json[key] = values[i];
|
||||||
});
|
});
|
||||||
return q.nfbind(fs.writeFile)(cacheFilepath, JSON.stringify(json));
|
return Promise.promisify(fs.writeFile)(cacheFilepath, JSON.stringify(json));
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
this._persisting = null;
|
this._persisting = null;
|
||||||
|
|
|
@ -15,7 +15,7 @@ jest
|
||||||
.dontMock('crypto')
|
.dontMock('crypto')
|
||||||
.dontMock('../Cache');
|
.dontMock('../Cache');
|
||||||
|
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
|
|
||||||
describe('JSTransformer Cache', function() {
|
describe('JSTransformer Cache', function() {
|
||||||
var Cache;
|
var Cache;
|
||||||
|
@ -32,7 +32,7 @@ describe('JSTransformer Cache', function() {
|
||||||
it('calls loader callback for uncached file', function() {
|
it('calls loader callback for uncached file', function() {
|
||||||
var cache = new Cache({projectRoots: ['/rootDir']});
|
var cache = new Cache({projectRoots: ['/rootDir']});
|
||||||
var loaderCb = jest.genMockFn().mockImpl(function() {
|
var loaderCb = jest.genMockFn().mockImpl(function() {
|
||||||
return q();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
cache.get('/rootDir/someFile', loaderCb);
|
cache.get('/rootDir/someFile', loaderCb);
|
||||||
expect(loaderCb).toBeCalledWith('/rootDir/someFile');
|
expect(loaderCb).toBeCalledWith('/rootDir/someFile');
|
||||||
|
@ -48,7 +48,7 @@ describe('JSTransformer Cache', function() {
|
||||||
});
|
});
|
||||||
var cache = new Cache({projectRoots: ['/rootDir']});
|
var cache = new Cache({projectRoots: ['/rootDir']});
|
||||||
var loaderCb = jest.genMockFn().mockImpl(function() {
|
var loaderCb = jest.genMockFn().mockImpl(function() {
|
||||||
return q('lol');
|
return Promise.resolve('lol');
|
||||||
});
|
});
|
||||||
return cache.get('/rootDir/someFile', loaderCb).then(function(value) {
|
return cache.get('/rootDir/someFile', loaderCb).then(function(value) {
|
||||||
expect(value).toBe('lol');
|
expect(value).toBe('lol');
|
||||||
|
@ -65,7 +65,7 @@ describe('JSTransformer Cache', function() {
|
||||||
});
|
});
|
||||||
var cache = new Cache({projectRoots: ['/rootDir']});
|
var cache = new Cache({projectRoots: ['/rootDir']});
|
||||||
var loaderCb = jest.genMockFn().mockImpl(function() {
|
var loaderCb = jest.genMockFn().mockImpl(function() {
|
||||||
return q('lol');
|
return Promise.resolve('lol');
|
||||||
});
|
});
|
||||||
return cache.get('/rootDir/someFile', loaderCb).then(function() {
|
return cache.get('/rootDir/someFile', loaderCb).then(function() {
|
||||||
var shouldNotBeCalled = jest.genMockFn();
|
var shouldNotBeCalled = jest.genMockFn();
|
||||||
|
@ -152,7 +152,7 @@ describe('JSTransformer Cache', function() {
|
||||||
|
|
||||||
var cache = new Cache({projectRoots: ['/rootDir']});
|
var cache = new Cache({projectRoots: ['/rootDir']});
|
||||||
var loaderCb = jest.genMockFn().mockImpl(function() {
|
var loaderCb = jest.genMockFn().mockImpl(function() {
|
||||||
return q('new value');
|
return Promise.resolve('new value');
|
||||||
});
|
});
|
||||||
|
|
||||||
return cache.get('/rootDir/someFile', loaderCb).then(function(value) {
|
return cache.get('/rootDir/someFile', loaderCb).then(function(value) {
|
||||||
|
@ -193,13 +193,13 @@ describe('JSTransformer Cache', function() {
|
||||||
|
|
||||||
var cache = new Cache({projectRoots: ['/rootDir']});
|
var cache = new Cache({projectRoots: ['/rootDir']});
|
||||||
cache.get('/rootDir/bar', function() {
|
cache.get('/rootDir/bar', function() {
|
||||||
return q('bar value');
|
return Promise.resolve('bar value');
|
||||||
});
|
});
|
||||||
cache.get('/rootDir/foo', function() {
|
cache.get('/rootDir/foo', function() {
|
||||||
return q('foo value');
|
return Promise.resolve('foo value');
|
||||||
});
|
});
|
||||||
cache.get('/rootDir/baz', function() {
|
cache.get('/rootDir/baz', function() {
|
||||||
return q('baz value');
|
return Promise.resolve('baz value');
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.runAllTicks();
|
jest.runAllTicks();
|
||||||
|
|
|
@ -9,14 +9,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
var Cache = require('./Cache');
|
var Cache = require('./Cache');
|
||||||
var _ = require('underscore');
|
|
||||||
var workerFarm = require('worker-farm');
|
var workerFarm = require('worker-farm');
|
||||||
var declareOpts = require('../lib/declareOpts');
|
var declareOpts = require('../lib/declareOpts');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
var readFile = q.nfbind(fs.readFile);
|
var readFile = Promise.promisify(fs.readFile);
|
||||||
|
|
||||||
module.exports = Transformer;
|
module.exports = Transformer;
|
||||||
Transformer.TransformError = TransformError;
|
Transformer.TransformError = TransformError;
|
||||||
|
@ -63,12 +62,14 @@ function Transformer(options) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.transformModulePath == null) {
|
if (options.transformModulePath == null) {
|
||||||
this._failedToStart = q.Promise.reject(new Error('No transfrom module'));
|
this._failedToStart = Promise.reject(new Error('No transfrom module'));
|
||||||
} else {
|
} else {
|
||||||
this._workers = workerFarm(
|
this._workers = workerFarm(
|
||||||
{autoStart: true, maxConcurrentCallsPerWorker: 1},
|
{autoStart: true, maxConcurrentCallsPerWorker: 1},
|
||||||
options.transformModulePath
|
options.transformModulePath
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._transform = Promise.promisify(this._workers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,13 +87,13 @@ Transformer.prototype.loadFileAndTransform = function(filePath) {
|
||||||
return this._failedToStart;
|
return this._failedToStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
var workers = this._workers;
|
var transform = this._transform;
|
||||||
return this._cache.get(filePath, function() {
|
return this._cache.get(filePath, function() {
|
||||||
return readFile(filePath)
|
return readFile(filePath)
|
||||||
.then(function(buffer) {
|
.then(function(buffer) {
|
||||||
var sourceCode = buffer.toString();
|
var sourceCode = buffer.toString();
|
||||||
|
|
||||||
return q.nfbind(workers)({
|
return transform({
|
||||||
sourceCode: sourceCode,
|
sourceCode: sourceCode,
|
||||||
filename: filePath,
|
filename: filePath,
|
||||||
}).then(
|
}).then(
|
||||||
|
|
|
@ -11,13 +11,12 @@
|
||||||
jest
|
jest
|
||||||
.setMock('worker-farm', function() { return function() {};})
|
.setMock('worker-farm', function() { return function() {};})
|
||||||
.dontMock('path')
|
.dontMock('path')
|
||||||
.dontMock('q')
|
|
||||||
.dontMock('os')
|
.dontMock('os')
|
||||||
.dontMock('underscore')
|
.dontMock('underscore')
|
||||||
.setMock('uglify-js')
|
.setMock('uglify-js')
|
||||||
.dontMock('../');
|
.dontMock('../');
|
||||||
|
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
|
|
||||||
describe('Packager', function() {
|
describe('Packager', function() {
|
||||||
var getDependencies;
|
var getDependencies;
|
||||||
|
@ -56,7 +55,7 @@ describe('Packager', function() {
|
||||||
];
|
];
|
||||||
|
|
||||||
getDependencies.mockImpl(function() {
|
getDependencies.mockImpl(function() {
|
||||||
return q({
|
return Promise.resolve({
|
||||||
mainModuleId: 'foo',
|
mainModuleId: 'foo',
|
||||||
dependencies: modules
|
dependencies: modules
|
||||||
});
|
});
|
||||||
|
@ -64,7 +63,7 @@ describe('Packager', function() {
|
||||||
|
|
||||||
require('../../JSTransformer').prototype.loadFileAndTransform
|
require('../../JSTransformer').prototype.loadFileAndTransform
|
||||||
.mockImpl(function(path) {
|
.mockImpl(function(path) {
|
||||||
return q({
|
return Promise.resolve({
|
||||||
code: 'transformed ' + path,
|
code: 'transformed ' + path,
|
||||||
sourceCode: 'source ' + path,
|
sourceCode: 'source ' + path,
|
||||||
sourcePath: path
|
sourcePath: path
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
var Promise = require('q').Promise;
|
|
||||||
var Transformer = require('../JSTransformer');
|
var Transformer = require('../JSTransformer');
|
||||||
var DependencyResolver = require('../DependencyResolver');
|
var DependencyResolver = require('../DependencyResolver');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
@ -140,7 +139,7 @@ Packager.prototype._transformModule = function(module) {
|
||||||
var transform;
|
var transform;
|
||||||
|
|
||||||
if (module.isAsset) {
|
if (module.isAsset) {
|
||||||
transform = q(generateAssetModule(module));
|
transform = Promise.resolve(generateAssetModule(module));
|
||||||
} else {
|
} else {
|
||||||
transform = this._transformer.loadFileAndTransform(
|
transform = this._transformer.loadFileAndTransform(
|
||||||
path.resolve(module.path)
|
path.resolve(module.path)
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.setMock('worker-farm', function() { return function() {}; })
|
jest.setMock('worker-farm', function() { return function() {}; })
|
||||||
.dontMock('q')
|
|
||||||
.dontMock('os')
|
.dontMock('os')
|
||||||
.dontMock('path')
|
.dontMock('path')
|
||||||
.dontMock('url')
|
.dontMock('url')
|
||||||
|
@ -21,7 +20,7 @@ jest.setMock('worker-farm', function() { return function() {}; })
|
||||||
.setMock('uglify-js')
|
.setMock('uglify-js')
|
||||||
.dontMock('../');
|
.dontMock('../');
|
||||||
|
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
|
|
||||||
describe('processRequest', function() {
|
describe('processRequest', function() {
|
||||||
var server;
|
var server;
|
||||||
|
@ -36,18 +35,19 @@ describe('processRequest', function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
var makeRequest = function(requestHandler, requrl) {
|
var makeRequest = function(requestHandler, requrl) {
|
||||||
var deferred = q.defer();
|
return new Promise(function(resolve) {
|
||||||
requestHandler({
|
requestHandler(
|
||||||
url: requrl
|
{ url: requrl },
|
||||||
},{
|
{
|
||||||
end: function(res) {
|
end: function(res) {
|
||||||
deferred.resolve(res);
|
resolve(res);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
next: function() {}
|
||||||
}
|
}
|
||||||
},{
|
);
|
||||||
next: function() {}
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
return deferred.promise;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var invalidatorFunc = jest.genMockFunction();
|
var invalidatorFunc = jest.genMockFunction();
|
||||||
|
@ -60,7 +60,7 @@ describe('processRequest', function() {
|
||||||
FileWatcher = require('../../FileWatcher');
|
FileWatcher = require('../../FileWatcher');
|
||||||
|
|
||||||
Packager.prototype.package = jest.genMockFunction().mockImpl(function() {
|
Packager.prototype.package = jest.genMockFunction().mockImpl(function() {
|
||||||
return q({
|
return Promise.resolve({
|
||||||
getSource: function() {
|
getSource: function() {
|
||||||
return 'this is the source';
|
return 'this is the source';
|
||||||
},
|
},
|
||||||
|
@ -156,7 +156,7 @@ describe('processRequest', function() {
|
||||||
var packageFunc = jest.genMockFunction();
|
var packageFunc = jest.genMockFunction();
|
||||||
packageFunc
|
packageFunc
|
||||||
.mockReturnValueOnce(
|
.mockReturnValueOnce(
|
||||||
q({
|
Promise.resolve({
|
||||||
getSource: function() {
|
getSource: function() {
|
||||||
return 'this is the first source';
|
return 'this is the first source';
|
||||||
},
|
},
|
||||||
|
@ -164,7 +164,7 @@ describe('processRequest', function() {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.mockReturnValue(
|
.mockReturnValue(
|
||||||
q({
|
Promise.resolve({
|
||||||
getSource: function() {
|
getSource: function() {
|
||||||
return 'this is the rebuilt source';
|
return 'this is the rebuilt source';
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ var declareOpts = require('../lib/declareOpts');
|
||||||
var FileWatcher = require('../FileWatcher');
|
var FileWatcher = require('../FileWatcher');
|
||||||
var Packager = require('../Packager');
|
var Packager = require('../Packager');
|
||||||
var Activity = require('../Activity');
|
var Activity = require('../Activity');
|
||||||
var q = require('q');
|
var Promise = require('bluebird');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
|
||||||
module.exports = Server;
|
module.exports = Server;
|
||||||
|
@ -123,7 +123,7 @@ Server.prototype._rebuildPackages = function() {
|
||||||
Object.keys(packages).forEach(function(key) {
|
Object.keys(packages).forEach(function(key) {
|
||||||
var options = getOptionsFromUrl(key);
|
var options = getOptionsFromUrl(key);
|
||||||
// Wait for a previous build (if exists) to finish.
|
// Wait for a previous build (if exists) to finish.
|
||||||
packages[key] = (packages[key] || q()).finally(function() {
|
packages[key] = (packages[key] || Promise.resolve()).finally(function() {
|
||||||
// With finally promise callback we can't change the state of the promise
|
// With finally promise callback we can't change the state of the promise
|
||||||
// so we need to reassign the promise.
|
// so we need to reassign the promise.
|
||||||
packages[key] = buildPackage(options).then(function(p) {
|
packages[key] = buildPackage(options).then(function(p) {
|
||||||
|
@ -154,7 +154,7 @@ Server.prototype._informChangeWatchers = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype.end = function() {
|
Server.prototype.end = function() {
|
||||||
q.all([
|
Promise.all([
|
||||||
this._fileWatcher.end(),
|
this._fileWatcher.end(),
|
||||||
this._packager.kill(),
|
this._packager.kill(),
|
||||||
]);
|
]);
|
||||||
|
@ -188,7 +188,7 @@ Server.prototype._processDebugRequest = function(reqUrl, res) {
|
||||||
res.end(ret);
|
res.end(ret);
|
||||||
} else if (parts[1] === 'packages') {
|
} else if (parts[1] === 'packages') {
|
||||||
ret += '<h1> Cached Packages </h1>';
|
ret += '<h1> Cached Packages </h1>';
|
||||||
q.all(Object.keys(this._packages).map(function(url) {
|
Promise.all(Object.keys(this._packages).map(function(url) {
|
||||||
return this._packages[url].then(function(p) {
|
return this._packages[url].then(function(p) {
|
||||||
ret += '<div><h2>' + url + '</h2>';
|
ret += '<div><h2>' + url + '</h2>';
|
||||||
ret += p.getDebugInfo();
|
ret += p.getDebugInfo();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче