Gulp 语法高亮-建筑:loadReposFromCache(...),错误不是函数

rdrgkggo  于 2022-12-08  发布在  Gulp
关注(0)|答案(2)|浏览(176)

我正在尝试使用SyntaxHighlighter v4插件,但我无法让构建过程工作!
按照here指令,我得到以下错误:

$ ./node_modules/gulp/bin/gulp.js setup-project
[10:12:20] Requiring external module babel-register
[10:12:20] Using gulpfile C:\git\syntaxhighlighter\gulpfile.babel.js
[10:12:20] Starting 'setup-project:clone-repos'...
[10:12:20] 'setup-project:clone-repos' errored after 1.96 ms
[10:12:20] TypeError: loadReposFromCache(...).error is not a function
    at loadRepos (C:/git/syntaxhighlighter/build/setup-project.js:39:48)
    at Gulp.<anonymous> (C:/git/syntaxhighlighter/build/setup-project.js:48:5)
    at module.exports (C:\git\syntaxhighlighter\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (C:\git\syntaxhighlighter\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\git\syntaxhighlighter\node_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (C:\git\syntaxhighlighter\node_modules\orchestrator\index.js:134:8)
    at C:\git\syntaxhighlighter\node_modules\gulp\bin\gulp.js:129:20
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:606:11)
(node:2532) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open 'C:\git\syntaxhighlighter\.projects-cache.json'

似乎没有将github仓库文件导入到/repos/目录中。我可以手动操作吗?有没有其他方法可以构建它以便我可以使用它?或者甚至像v3中那样找到构建的文件?
下面是在build/setup-project.js中失败的函数

gulp.task('setup-project:clone-repos', 'Clones all repositories from 
  SyntaxHighlighter GitHub organization', () =>
    loadRepos()
      .then(R.filter(repo => !fs.existsSync(pathToRepo(repo))))
      .then(R.filter(repo => repo.name !== 'syntaxhighlighter'))
      .then(R.map(R.curry(cloneRepo)))
      .then(Promise.all)
);

追溯我们看到:

const loadReposFromCache = () => fs.readFile.promise(REPOS_CACHE, 'utf8').then(JSON.parse);
const loadRepos = () => loadReposFromCache().error(loadReposFromGitHub).then(R.map(R.pick(['clone_url', 'name'])));

function loadReposFromGitHub() {
  const request = require('request');

  const opts = {
    url: 'https://api.github.com/orgs/syntaxhighlighter/repos?per_page=300',
    json: true,
    headers: { 'User-Agent': 'node.js' },
  };

  return new Promise((resolve, reject) =>
    request(opts, (err, response) => {
      if (err) return reject(err);
      const json = response.body;
      fs.writeFile(REPOS_CACHE, JSON.stringify(json, null, 2));
      resolve(json);
    })
  );
}
qybjjes1

qybjjes11#

在该项目的构建代码中有几个问题。
对于这里的特定问题,蓝鸟承诺上的Songbird Package 器似乎不再匹配-因此“.error不是函数”(在Songbird上,但在蓝鸟上可以)。
因此,将.error替换为.catch或将require('songbird')替换为require('bluebird')
无论是哪种情况,这都只是构建问题的开始...
我已经把这个添加到项目的问题跟踪无论如何,但这里是我做了什么得到它的建设:https://github.com/karljacuncha/syntaxhighlighter/commit/dc015fa299d4d249e8518664e205a838c55372cf

4dbbbstv

4dbbbstv2#

构建再次中断(2021年4月)。我将项目从karljacuncha's answer分叉,并将对fs.writeFile的调用更改为fs.writeFileSync
https://github.com/BartJolling/syntaxhighlighter/commit/7dbd08203cba8ef3be72cbe1abbfb3475be19ef4
我还包括了我在更大的社区中发现的其他修复程序,并且我还修复了-output参数的用法。

相关问题