소스 검색

Checks for plugin type and plugin id rather than name

Richard Willars 7 년 전
부모
커밋
b0eb6c0a7e
1개의 변경된 파일7개의 추가작업 그리고 7개의 파일을 삭제
  1. 7 7
      src/core/Core.js

+ 7 - 7
src/core/Core.js

@@ -609,21 +609,21 @@ class Uppy {
 
 
     // Instantiate
     // Instantiate
     const plugin = new Plugin(this, opts)
     const plugin = new Plugin(this, opts)
-    const pluginName = plugin.id
+    const pluginId = plugin.id
     this.plugins[plugin.type] = this.plugins[plugin.type] || []
     this.plugins[plugin.type] = this.plugins[plugin.type] || []
 
 
-    if (!pluginName) {
-      throw new Error('Your plugin must have a name')
+    if (!pluginId) {
+      throw new Error('Your plugin must have an id')
     }
     }
 
 
-    if (!plugin.type) {
+    if (!plugin.type || plugin.type === 'none') {
       throw new Error('Your plugin must have a type')
       throw new Error('Your plugin must have a type')
     }
     }
 
 
-    let existsPluginAlready = this.getPlugin(pluginName)
+    let existsPluginAlready = this.getPlugin(pluginId)
     if (existsPluginAlready) {
     if (existsPluginAlready) {
-      let msg = `Already found a plugin named '${existsPluginAlready.name}'.
-        Tried to use: '${pluginName}'.
+      let msg = `Already found a plugin named '${existsPluginAlready.id}'.
+        Tried to use: '${pluginId}'.
         Uppy is currently limited to running one of every plugin.
         Uppy is currently limited to running one of every plugin.
         Share your use case with us over at
         Share your use case with us over at
         https://github.com/transloadit/uppy/issues/
         https://github.com/transloadit/uppy/issues/