isomorphi c - git clone () TypeError: невозможно прочитать свойство 'bind' неопределенного значения - PullRequest
0 голосов
/ 03 августа 2020

Я хотел бы использовать isomorphi c - git с BrowserFS на Kintone (который не поддерживает импорт модулей).

Я не контролирую теги скрипта, но это как они включаются в результирующую страницу:

<script src="https://unpkg.com/isomorphic-git@1.7.4"></script>
<script src="https://unpkg.com/browserfs"></script>

Затем я инициализирую BrowserFS для использования IndexedDB браузера в качестве файловой системы:

(new Promise((resolve,reject)=> {
  BrowserFS.getFileSystem({
    fs: "IndexedDB",
    options: {}
  }, function(error,fs) {
    if (error) {
      BrowserFS.configure({
        fs: "IndexedDB",
        options: {}
      }, function(error) {
        if (error) {
          reject(error)
        }
        const fs = BrowserFS.BFSRequire("fs")
        BrowserFS.BFSRequire("path")
        resolve(fs)
      })
    }
    resolve(BrowserFS.initialize(fs))
  })
})).then(fs => {
  ...

Наконец, я использую динамический c импорт для модуля isomorphi c - git:

  return import('https://unpkg.com/isomorphic-git@1.7.4/http/web/index.js').then(http => {
    window.http = http
    return true
  })
}).then(response => {
  ...

Когда я пытаюсь запустить команду git clone ...

  return git.clone({
    fs,
    http,
    dir:stagingRoot,
    corsProxy: 'https://cors.isomorphic-git.org',
    url: repositoryURL.getValue(),
    ref: branch.getValue(),
    onAuth: url => {
      const auth = {
        username: username.getValue(),
        password: password.getValue(),
      }
      return auth
    },
    singleBranch: true,
    depth: 100
  })
}).then(response => {
  ...

я получаю следующее TypeError:

Uncaught (in promise) TypeError: Cannot read property 'bind' of undefined
    at new u (isomorphic-git@1.7.4:formatted:157)
    at Module.<anonymous> (isomorphic-git@1.7.4:formatted:13793)
    at Generator.next (<anonymous>)
    at Qt (isomorphic-git@1.7.4:formatted:13757)
    at a (isomorphic-git@1.7.4:formatted:13771)
    at isomorphic-git@1.7.4:formatted:13776
    at new Promise (<anonymous>)
at Module.<anonymous> (isomorphic-git@1.7.4:formatted:13768)
at Module.re (isomorphic-git@1.7.4:formatted:13821)
at Module.ee (isomorphic-git@1.7.4:formatted:13782)

Есть идеи, откуда это?

1 Ответ

0 голосов
/ 05 августа 2020

Это была простая проблема с упорядочением импорта тегов скрипта. Правильный порядок был:

<script src="https://unpkg.com/browserfs"></script>
<script src="https://unpkg.com/isomorphic-git@1.7.4"></script>

У меня были другие проблемы с BrowserFS, поэтому я вернулся к isomorphi c - git при условии lightning-fs ...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...