Просмотр исходного кода

Remove dependency of bluebird

udpate package.json
Sotaro KARASAWA 9 лет назад
Родитель
Сommit
ba2035a204

+ 2 - 4
lib/crowi/index.js

@@ -6,7 +6,6 @@ var debug = require('debug')('crowi:crowi')
   , path = require('path')
   , fs = require('fs')
   , sep = path.sep
-  , Promise = require('bluebird')
 
   , mongoose    = require('mongoose')
 
@@ -55,7 +54,6 @@ function Crowi (rootdir, env)
   };
 
   if (this.node_env == 'development') {
-    Promise.longStackTraces();
   }
 
   //time.tzset('Asia/Tokyo');
@@ -64,7 +62,7 @@ function Crowi (rootdir, env)
 Crowi.prototype.init = function() {
   var self = this;
 
-  return new Promise.resolve()
+  return Promise.resolve()
   .then(function() {
     // setup database server and load all modesl
     return self.setupDatabase();
@@ -330,7 +328,7 @@ Crowi.prototype.buildServer = function() {
     });
   }
 
-  return new Promise.resolve(app);
+  return Promise.resolve(app);
 };
 
 Crowi.prototype.exitOnError = function(err) {

+ 0 - 1
lib/models/attachment.js

@@ -2,7 +2,6 @@ module.exports = function(crowi) {
   var debug = require('debug')('crowi:models:attachment')
     , mongoose = require('mongoose')
     , ObjectId = mongoose.Schema.Types.ObjectId
-    , Promise = require('bluebird')
     , fileUploader = require('../util/fileUploader')(crowi)
   ;
 

+ 9 - 8
lib/routes/attachment.js

@@ -5,7 +5,6 @@ module.exports = function(crowi, app) {
     , Attachment = crowi.model('Attachment')
     , User = crowi.model('User')
     , Page = crowi.model('Page')
-    , Promise = require('bluebird')
     , config = crowi.getConfig()
     , fs = require('fs')
     , fileUploader = require('../util/fileUploader')(crowi, app)
@@ -118,19 +117,21 @@ module.exports = function(crowi, app) {
 
           result.page.creator = User.filterToPublicFields(result.page.creator);
           result.attachment.creator = User.filterToPublicFields(result.attachment.creator);
+
+          // delete anyway
+          fs.unlink(tmpPath, function (err) { if (err) { debug('Error while deleting tmp file.'); } });
+
           return res.json(ApiResponse.success(result));
         }).catch(function (err) {
           debug('Error on saving attachment data', err);
           // @TODO
           // Remove from S3
+
+          // delete anyway
+          fs.unlink(tmpPath, function (err) { if (err) { debug('Error while deleting tmp file.'); } });
+
           return res.json(ApiResponse.error('Error while uploading.'));
-        }).finally(function() {
-          fs.unlink(tmpPath, function (err) {
-            if (err) {
-              debug('Error while deleting tmp file.');
-            }
-          });
-        })
+        });
       ;
     }).catch(function(err) {
       debug('Attachement upload error', err);

+ 1 - 2
local_modules/crowi-fileupload-aws/index.js

@@ -5,7 +5,6 @@ module.exports = function(crowi) {
 
   var aws = require('aws-sdk')
     , debug = require('debug')('crowi:lib:fileUploaderAws')
-    , Promise = require('bluebird')
     , Config = crowi.model('Config')
     , config = crowi.getConfig()
     , lib = {}
@@ -29,7 +28,7 @@ module.exports = function(crowi) {
   lib.uploadFile = function(filePath, contentType, fileStream, options) {
     var awsConfig = getAwsConfig();
     if (!Config.isUploadable(config)) {
-      return new Promise.reject(new Error('AWS is not configured.'));
+      return Promise.reject(new Error('AWS is not configured.'));
     }
 
     aws.config.update({

+ 0 - 1
package.json

@@ -36,7 +36,6 @@
     "babel-preset-es2015": "~6.6.0",
     "babel-preset-react": "~6.5.0",
     "basic-auth-connect": "~1.0.0",
-    "bluebird": "~3.0.5",
     "body-parser": "~1.14.1",
     "bootstrap-sass": "~3.3.6",
     "botkit": "~0.1.1",

+ 0 - 1
test/bootstrap.js

@@ -4,7 +4,6 @@ var express = require('express')
   , async = require('async')
   , ROOT_DIR = __dirname + '/..'
   , MODEL_DIR = __dirname + '/../lib/models'
-  , Promise = require('bluebird')
   , testDBUtil
   ;
 

+ 0 - 1
test/crowi/crowi.test.js

@@ -5,7 +5,6 @@ var chai = require('chai')
   , proxyquire = require('proxyquire')
 
   , path = require('path')
-  , Promise = require('bluebird')
   ;
 chai.use(sinonChai);
 

+ 0 - 1
test/models/config.test.js

@@ -2,7 +2,6 @@ var chai = require('chai')
   , expect = chai.expect
   , sinon = require('sinon')
   , sinonChai = require('sinon-chai')
-  , Promise = require('bluebird')
   , utils = require('../utils.js')
   ;
 chai.use(sinonChai);

+ 0 - 1
test/models/page.test.js

@@ -2,7 +2,6 @@ var chai = require('chai')
   , expect = chai.expect
   , sinon = require('sinon')
   , sinonChai = require('sinon-chai')
-  , Promise = require('bluebird')
   , utils = require('../utils.js')
   ;
 chai.use(sinonChai);

+ 0 - 1
test/models/updatePost.test.js

@@ -2,7 +2,6 @@ var chai = require('chai')
   , expect = chai.expect
   , sinon = require('sinon')
   , sinonChai = require('sinon-chai')
-  , Promise = require('bluebird')
   , utils = require('../utils.js')
   ;
 chai.use(sinonChai);