小编Nik*_*hev的帖子

在 dockerising nest.js 应用程序上出错

我正在开发一个 Nest.js 应用程序,这是我们拥有的 Dockerfile。当我运行它时,我npm run build在 docker的步骤中遇到错误。这是 package.json 中的构建任务。 "build": "nest build"

sh: nest: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! atom-qbuilder-api@0.0.1 build: `nest build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the atom-qbuilder-api@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Run Code Online (Sandbox Code Playgroud)

文件

# Build
FROM node:8-alpine as builder

COPY package.json …
Run Code Online (Sandbox Code Playgroud)

docker nestjs

8
推荐指数
1
解决办法
3285
查看次数

Vim:snipMate插件不会触发代码段完成

Vim安装在/ usr/share/vim.

所有snipMate的文件夹都相应地添加到现有文件夹(自动加载,自动加载,插件,代码段等)中的此类别中.

从文档文件:

For instance, to change the trigger
key to CTRL-J, just change this:

ino <tab> <c-r>=TriggerSnippet()<cr> 
snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>

to this: 
ino <c-j> <c-r>=TriggerSnippet()<cr>  
snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
Run Code Online (Sandbox Code Playgroud)

我也试过这个 - 结果相同.当我尝试触发片段匹配时,它只添加一个选项卡(4个空格,相应于我的.vimrc).

PS文件类型插件缩进.

更新:

cat /etc/issue
Ubuntu 9.10
Run Code Online (Sandbox Code Playgroud)

下:inoremap

i  <C-B>       * <C-R>=TriggerSnippet()<CR>
Run Code Online (Sandbox Code Playgroud)

:snoremap

s  <C-B>       * <Esc>i<Right><C-R>=TriggerSnippet()<CR>
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

vim snipmate

7
推荐指数
2
解决办法
8809
查看次数

链轮 - 多个入口点?

链轮官方文档清楚地说:

Sprockets takes any number of source files and preprocesses them
line-by-line in order to build a `single` concatenation.
Run Code Online (Sandbox Code Playgroud)

我是Rails中链轮的忠实粉丝,但这就是问题 - 我的应用程序必须支持多种布局(桌面浏览器)和移动客户端(iphone,ipad,android手机等).

这两种布局都需要自己的HTML重置CSS规则.桌面和移动重置文件的连接规则会产生冲突,因为它们会覆盖低级CSS指令.

我该如何解决这个问题?

css ruby-on-rails ruby-on-rails-3.1 sprockets

7
推荐指数
1
解决办法
1145
查看次数

使用 RSpec 和 Rails 测试模型中的验证

我对使用 RSpec 测试我的应用程序非常陌生,我正在尝试在没有用户的情况下测试评论的验证,并不断出现语法错误。这是评论模型代码。

class Comment < ApplicationRecord
  belongs_to :user
  belongs_to :product

  scope :rating_desc, -> { order(rating: :desc) }

  validates :body, presence: true
  validates :user, presence: true
  validates :product, presence: true
  validates :rating, numericality: { only_integer: true }

  after_create_commit { CommentUpdateJob.perform_later(self, user) }
end
Run Code Online (Sandbox Code Playgroud)

这是评论规范:

require 'rails_helper'

describe Comment do 
  before do 
    @product = Product.create!(name: "race bike", description: "fast race bike")
        @user = User.create!(email: "jerryhoglen@me.com", password: "Maggie1!")
        @product.comments.create!(rating: 1, user: @user, body: "Awful bike!")
  end

  it "is invalid without a user" …
Run Code Online (Sandbox Code Playgroud)

ruby validation rspec model ruby-on-rails

7
推荐指数
1
解决办法
7726
查看次数

Angular 如何使 [formControl] 成为可选字段

在 Angular 中,您可以向输入添加属性并使用 attr 将它们设为可选:

<input [type]="text" [attr.id]="id">
Run Code Online (Sandbox Code Playgroud)

但是如何使表单控件成为可选的呢?我想要这样的东西:

<input [type]="text" [attr.formControl]="someControl">
Run Code Online (Sandbox Code Playgroud)

如果 someControl 未定义或为空,则不会设置 formControl 在哪里?

angular2-forms angular

7
推荐指数
1
解决办法
5588
查看次数

Cypress cy.request 期望抛出/失败

有什么方法可以编写一个测试用例,以期望cy.request在某些参数上失败(非 2** 响应)?

我尝试使用以下代码片段:

it('intentionally fails', () => {
  expect(
    () => {
      cy.request({
        method: 'POST',
        url: `https://valid.url/api/items`,
        body: {name: "foo"},
      })
    }
  ).to.throw('bar')
})
Run Code Online (Sandbox Code Playgroud)

但它失败了:

AssertionError
expected [Function] to throw an error
Run Code Online (Sandbox Code Playgroud)

这是仅 API 的项目,所以基本上我只cy.request在任何地方使用。

如果没有expect功能块,它会失败并显示:

CypressError
cy.request() failed on

The response we received from your web server was:

  > 500: Internal Server Error
Run Code Online (Sandbox Code Playgroud)

javascript chai cypress

7
推荐指数
1
解决办法
1万
查看次数

在 Emacs 中停用特定的 yasnippet

随着Yasnippet近日从MELPA更新,我希望能够结束只有片段xxx,并todo附带文本模式。第一个扩展为x,另一个扩展为t,这让我很困扰,因为我在组织模式下编写数学文本,我需要自己写几个x's 和t's,然后按TAB退出括号。

从yas-buffer-local-condition来看,如果#condition:片段中有指令,我似乎可以做一些事情,但提到的片段没有。

如果我只是删除文件,我就可以了,但不幸的是,它们会在 Yasnippet 的每次更新时重新出现。

emacs yasnippet

6
推荐指数
1
解决办法
899
查看次数

NoMethodError: 未定义的方法 `symbolize_keys!' 对于哈希

我正在尝试Hashie在 Rails 之外使用。在我的 rakefile 中,我已经包含了require hashie/hash,但我仍然得到NoMethodError. 我试过使用require hash; 那里也没有运气。

这是它失败的行:

YAML.load(ERB.new(File.read('../prefs.yml')).result)['dev'].symbolize_keys!
Run Code Online (Sandbox Code Playgroud)

当我inspect使用哈希时,它看起来是正确的并采用以下形式:{'key':'value'}. 我希望密钥是一个符号,但我不想在 Rails 3 和 4 之间切换,所以我安装Hashie了它并将其添加到我的 Rakefile 中,但这似乎并没有解决问题。

谁能告诉我为什么我可能会收到此错误?

hash rake ruby-on-rails rakefile

6
推荐指数
1
解决办法
3868
查看次数

通过 SQS 将消息发布到 Elastic Beanstalk 工作线程环境

我在弹性 beanstalk 上有一个带有 Web 服务器和工作环境的 docker 应用程序。

工作环境当前通过 cron 运行计划作业。我正在尝试将服务器连接到工作人员以实现以下目标:

  1. 客户端向服务器发送请求(/trigger_job)
  2. 服务器通过向 SQS 队列 (/perform_job) 发送 JSON 消息来将作业卸载给工作人员
  3. Worker 通过读取来自 SQS 的消息来执行作业

我无法找到有关 JSON 消息应是什么样子的文档。官方文档中提到了一些HTTP headers 。但没有提到标头来指定工作环境中所需的端点。

# server.py
from bottle import post, HTTPResponse


@post('/trigger_job')
def trigger_worker_job():
    # should send a JSON message to sqs to trigger the '/perform_job'
    # Need help with what the JSON message looks like
    return HTTPResponse(status=200, body={'Msg': 'Sent message'})
Run Code Online (Sandbox Code Playgroud)
# worker.py
from bottle import post, HTTPResponse


@post('/perform_job')
def perform_job():
    # job is performed …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-elastic-beanstalk

6
推荐指数
1
解决办法
2014
查看次数

NGRX 效果中的访问状态

如何在效果中访问我的状态?我当前的效果实现(如下所示)是在SEARCH_REUQUEST分派动作时触发的。但是,在调用我的搜索服务以启动 HTTP 请求之前,我想访问一个状态以获取一些搜索参数。

@Effect()
SearchRequest$ = this.actions$
  .ofType(fromSearchActions.SearchActionTypes.SEARCH_REQUEST)
  .pipe(
    switchMap((action: fromSearchActions.SearchRequest) => {
      return this.searchService
        .search(action.payload, action.enrichmentId)
        .pipe(
          map(response => {
            console.group("SEARCH effects");
            console.log(response);
            console.groupEnd();
            return new fromSearchActions.SearchRequestSuccess(response);
          }),
          catchError(error =>
            of(new fromSearchActions.SearchRequestFail(error))
          )
        );
    })
  );
Run Code Online (Sandbox Code Playgroud)

显然,我可以在这里利用一个 RxJS 运算符,但我似乎无法理解如何修改现有的效果实现以合并它。

@Effect()
SearchRequest$ = this.actions$
  .ofType(fromSearchActions.SearchActionTypes.SEARCH_REQUEST)
  .withLatestFrom(this.featureStore.select(fromFeature.getCurrentSearchPageOptions))
  .pipe(
      switchMap((// How should this change? //) => { //Error
        return this.searchService
          .search(action.payload, action.enrichmentId, pageOptions)
          .pipe(
            map(response => {
              console.group("SEARCH effects");
              console.log(response);
              console.groupEnd();
              return new fromSearchActions.SearchRequestSuccess(response);
            }),
            catchError(error =>
              of(new fromSearchActions.SearchRequestFail(error))
            ) …
Run Code Online (Sandbox Code Playgroud)

ngrx ngrx-effects angular ngrx-store-4.0

6
推荐指数
2
解决办法
4462
查看次数