我在一个新项目中使用Nx来支持 monorepo。Nx 的一个好处是它可以确定 monorepo 中的哪些应用程序受到一系列更改(开始提交、结束提交)的影响。因此,如果您有一堆应用程序,您只需构建、测试和部署实际受更改影响的应用程序,而不是整个 monorepo。
我想设置一个 GitHub Action 工作流程,以仅在推送或合并到 master 时部署受影响的应用程序。但是,我无法弄清楚如何获得更改范围的“开始提交”。换句话说,如何获取上次部署的提交哈希?
GitHub 提供了一个 env 变量,GITHUB_SHA但这是触发工作流程的提交(即“结束提交”)。它还提供GITHUB_BASE_REF但仅适用于从分叉仓库运行的工作流与头部仓库相比。
CircleCIpipeline.git.base_revision为此目的。GitHub Actions 有类似的东西吗?
假设我有一个如下组件:
@Component({
selector: 'example',
template: ` `
})
export class ExampleComponent {
value: any;
@Output() output: EventEmitter<any> = new EventEmitter();
onValueChange(newValue: any) {
if (newValue !== this.value) {
this.value = newValue;
this.output.emit(newValue);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我写了一个类似下面的测试.我想测试如果onValueChange使用相同的值调用value,组件将不输出重复值.是否存在单元测试的最佳实践,即永远不会调用可观察的订阅?虽然我在技术上的工作,但感觉有点hacky.
describe('ExampleComponent', () => {
it('should not output duplicate values', () => {
const component = new ExampleComponent();
component.value = 1;
component.output.subscribe(value => {
// if the output is not triggered then we'll never reach this
// point and the test …Run Code Online (Sandbox Code Playgroud) 我升级了:> brew upgrade node安装了v5.3.0 的Node.js版本.但是当我得到节点的版本时,:> node -v它显示v0.10.29.
我试过:> brew link --overwrite node但是没用.
Brew有节点链接,/usr/local/Cellar/node/0.10.29所以我去那里注意到还有其他版本的节点,包括我想要的版本/usr/local/Cellar/node/.
如何告诉brew将节点链接到/usr/local/Cellar/node/5.3.0?
我找到了一个Node JS客户端https://www.npmjs.com/package/node-onedrive-unofficial。其中包含有限的功能。
是否有适用于OneDrive API的官方Node JS库/客户端?
我在测试一个 Angular 组件时遇到问题,该组件[(ngModel)]在ngFor. 它在实际应用中运行良好。这只是测试的问题。
这是一个失败的示例测试:
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { Component, EventEmitter, Output } from '@angular/core';
import { FormsModule } from '@angular/forms';
describe('Example Test', () => {
@Component({
template: `
<input *ngFor="let value of values"
type="checkbox"
class="checkbox-1"
[(ngModel)]="value.isSelected"
(change)="output.emit(values)">
`,
styles: [``]
})
class TestHostComponent {
@Output() output: EventEmitter<any> = new EventEmitter();
values = [
{ isSelected: true },
{ isSelected: true },
{ isSelected: true },
];
} …Run Code Online (Sandbox Code Playgroud)