当用作npm脚本参数时,是否可以调出从yargs中检索密钥?
OSX终端中的用户类型:
npm run scaffold --name=blah
Run Code Online (Sandbox Code Playgroud)
在package.json中执行:
"scaffold" : "node ./scaffold/index.js -- "
Run Code Online (Sandbox Code Playgroud)
这导致了
const yargs = require('yargs').argv
if (yargs) {
console.log(yargs);
console.log(yargs.name);
process.exit(1)
}
...
result:
{ _: [], '$0': 'scaffold/index.js' }
undefined
Run Code Online (Sandbox Code Playgroud)
这只适用于我在package.json中的硬编码"scaffold" : "node scaffold/index.js --name=blah",但我需要这个是可配置的.
正如我所说,我正在使用args,因为它似乎可以很容易地按名称检索密钥(而不是数组).接受建议.
我错过了什么?
更新11-07-2017 相关:将命令行参数发送到npm脚本
但是,传递命令行1: npm run scaffold name=hello
OR会2: npm run scaffold --name=hello产生:
1: { _: [], '$0': 'scaffold/index.js' }
2: { _: [ 'name=hello' ], '$0': 'scaffold/index.js' }
Run Code Online (Sandbox Code Playgroud)
仍然看不到检索yargs.name财产的方法.仍未定义.
暂时,我放弃了.这似乎是不可能的.我在终端中手动运行脚本.例如 …
找到一个简单的例子工作真的很麻烦.我使用的这个例子来自https://gist.github.com/Madhuka/7854709
describe("Test for spies", function() {
function sendRequest(callbacks, configuration) {
$.ajax({
url: configuration.url,
dataType: "json",
success: function(data) {
callbacks.checkForInformation(data);
},
error: function(data) {
callbacks.displayErrorMessage();
},
timeout: configuration.remainingCallTime
});
}
it("should make an Ajax request to the correct URL", function() {
var configuration = {
url : "http://www.google.com",
remainingCallTime : 30000
};
spyOn($, "ajax");
sendRequest(undefined, configuration);
expect($.ajax.mostRecentCall.args[0]["url"]).toEqual(configuration.url);
});
});
Run Code Online (Sandbox Code Playgroud)
无论出于何种原因,$.ajax.mostRecentCall都是未定义的.
使用jasmine 2.0.2和jasmine jquery 2.0.5.
使用Vuecli生成的Vue和webpack构建.有很多魔法在继续.我无法弄清楚的是如何生成IE所需的供应商前缀.
这是从github问题复制的:https://github.com/vuejs-templates/webpack/issues/421#issuecomment-284322065
VUE-loader.conf.js
var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'
module.exports = {
loaders: utils.cssLoaders({
sourceMap: isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap,
extract: isProduction
}),
postcss: [
require('postcss-import')(),
require('autoprefixer')({
browsers: ['ie >= 9']
})
]
}
Run Code Online (Sandbox Code Playgroud)
简单容器组件示例
容器/ index.vue
<template>
<div class="container">
<slot></slot>
</div>
</template>
<script>
import './index.scss'
export default {}
</script>
Run Code Online (Sandbox Code Playgroud)
容器/ index.scss
// this is aliased in webpack.base.conf
@import "~styles/base-config";
.container {
@include grid(); // this generates display:flex and …Run Code Online (Sandbox Code Playgroud) 我在页面上有一个角度元素,需要与其他非角度页面元素进行通信.
我正在创建指令元素,并将其附加到其目标div.我试图传递该创建的指令一个对象(ajax对象),它只包含属性.
问题是我无法弄清楚如何将这个ajax对象传递给指令,因为$ compile需要一个范围.当http结束,并且因为我必须=在指令中使用时,指令被覆盖.
请看我的插件:https://plnkr.co/edit/brTWgUWTotI44tECZXlQ (抱歉图片).单击<button>以触发指令.
(function() {
'use strict';
var CHANNEL = 'podOverlay';
angular.module('CavernUI', [])
.controller('CavernCtrl', function($scope,getItemService) {
$scope.model = {};
var _pods = $scope.model.pods = {};
function getData(selector) {
$(selector).each(function(i, pod) {
_pods[+pod.dataset.item] = {
$: $(pod)
};
});
Object.keys($scope.model.pods).map(function(key) {
getItemService.getItem(key).success(function(response) {
_pods[key] = angular.extend(_pods[key], response);
$scope.$broadcast(CHANNEL, _pods[key], $scope);
});
})
}
$scope.runPodCheck = function(selector) {
getData(selector);
}
})
.directive('podchecker', function($compile) {
var createOverlay = function(e,data,scope){
scope.data = data;
// can …Run Code Online (Sandbox Code Playgroud) 在这里绕圈子.对Typescript来说是一个新手,它引起了一些令人头疼的琐碎实现.
如何定义AgentStatusService它应该有一个名为4个选项的数组['offline','available','busy','away']?AgentStatus是定义的(或者是?),我将它注入到AgentStatusService.
Microsoft Visual Studio Code在第21行进行了barfing,其中类型'typeof AgentStatus'不能分配给'AgentStatus'类型...为什么?
更新:
import { EventEmitter, Injectable } from '@angular/core';
export enum AgentStatus {
available =1 ,
busy = 2,
away = 3,
offline = 0
}
export interface IAgentStatusService {
state: number
states: AgentStatus
}
@Injectable()
export class AgentStatusService implements IAgentStatusService {
state:number; // this really should be string, but line 22 returns a number
states:AgentStatus;
constructor(states:typeof AgentStatus = AgentStatus){
// unreacheable code browser_adapter.ts:78EXCEPTION: Error: Uncaught (in promise): …Run Code Online (Sandbox Code Playgroud) 最小的问题示例:https://codepen.io/sidouglas/pen/LYPZaOG
当输入范围集中在Chrome Vox或Mac的Voice over上时-的每个值valuetext都会连续读出。
<input
...
v-bind:aria-valuemax="valueMax"
v-bind:aria-valuenow="valueNow"
v-bind:aria-valuetext="currentTime + ' of ' + totalDuration"
...
/>
Run Code Online (Sandbox Code Playgroud)
将此与非常易于访问的https://plyr.io/#audio组件进行对比-当重点关注时,它会继续更新其aria值,但只向屏幕阅读器宣布两次。
有人知道吗?
<input
...
v-bind:aria-valuemax="valueMax"
v-bind:aria-valuenow="valueNow"
v-bind:aria-valuetext="currentTime + ' of ' + totalDuration"
...
/>
Run Code Online (Sandbox Code Playgroud)
new Vue({
el: '#range',
data: {
valueMax:100,
duration:100,
current:0,
totalDuration:'1:40'
},
computed:{
currentTime: function() {
return this.convertTime(this.current);
},
valueNow() {
return Math.round(this.current);
},
},
methods: {
convertTime(time) {
const minutes = Math.floor(time / 60);
const seconds = time …Run Code Online (Sandbox Code Playgroud)我无法弄清楚我与Susy的设置有什么问题.我在OS X 10.7.4上
我跟在这里:http://susy.oddbird.net/guides/getting-started/
错误
Syntax error: File to import not found or unreadable: susy.
Load paths:
Users/simon/Websites/wpsvntree/trunk/sass
/Users/simon/.gem/ruby/1.8/gems/compass-0.11.7/frameworks/blueprint/stylesheets
/Users/simon/.gem/ruby/1.8/gems/compass-0.11.7/frameworks/compass/stylesheets
Compass::SpriteImporter
on line 2 of /Users/simon/Websites/wpsvntree/trunk/sass/_base.sass
from line 2 of /Users/simon/Websites/wpsvntree/trunk/sass/screen.sass
Run Code Online (Sandbox Code Playgroud)
我安装的宝石:
*** LOCAL GEMS ***
chunky_png (1.2.6, 1.2.5)
compass (0.12.2, 0.11.7)
compass-boilerplate-plugin (0.1.0)
compass-h5bp (0.0.5, 0.0.2)
compass-rails (1.0.3)
fssm (0.2.9, 0.2.8.1)
html5-boilerplate (2.1.0)
sass (3.2.1, 3.1.15)
susy (1.0.3)
Run Code Online (Sandbox Code Playgroud)
我的config.rb文件位于项目的根目录中
require 'susy'
# Require any additional compass plugins here.
# Set this to the root of your …Run Code Online (Sandbox Code Playgroud) 停止完整的框架,如Angular,Knockout等,任何人都可以推荐一个简单的数据绑定jQuery插件?
购买车需要一个页面应用程序,需要在ajax完成后更新页面上的某些元素.只需要遍历字段并更新用户界面.
是的,我知道我可以自己写点东西,但是如果已经存在某些东西,我不想重新发明轮子.
我的研究引导我进入jquery.bindings - 但它并不受欢迎(只有一个贡献者)
建议?
Noob节点警告:如何以编程方式设置运行测试时要使用的配置对象?
一直在努力寻找明确的答案.
建立:
/e2e-tests
|-globals.js
|-product.page.notify.stock.js
|-nightwatch.json
|-nightwatch
Run Code Online (Sandbox Code Playgroud)
#!/usr/bin/env node require('nightwatch/bin/runner.js');var SITE_URL = 'http://dev.local/', //this needs to be set somehow production||dev
AJAX_URL = 'ajaxproc/getrandomoutofstock', //relative so this doesn't need to change
select = '#mysize',
emailError = '.error-message',
outOfStockItem = {
id: false,
url: false
};
module.exports = {
'Get backorder stock url': function(browser) {
browser.url(SITEURL + AJAX_URL)
// ommitted for brevity
},
'Check notify stock on product page': function(client) {
client.url(SITE_URL + outOfStockItem.url); …Run Code Online (Sandbox Code Playgroud)我对VueJS很新.在反应中,您可以轻松使用休息参数将道具传递给儿童.Vue中有类似的模式吗?
考虑具有一些子组件的父组件:
<template>
<header class="primary-nav">
<search-bar :config="searchBar"><search-bar>
// ^^^^ this becomes the key on the props for SearchBar
header>
</template>
export default {
data(){
return {
... a few components ...
searchBar : {
model: '',
name: 'search-bar',
placeholder: 'Search Away',
required:true,
another: true
andanother: true,
andonemoreanotherone:true,
thiscouldbehundredsofprops:true
}
}
}
}
<template>
<div :class="name">
<form action="/s" method="post">
<input type="checkbox">
<label :for="config.name" class="icon-search">{{config.label}}</label>
<text-input :config="computedTextInputProps"></text-input>
//^^^^ and so on. I don't like this config-dot property structure.
</form>
</div>
</template>
export …Run Code Online (Sandbox Code Playgroud) javascript ×5
vue.js ×3
ajax ×2
jquery ×2
angular ×1
angularjs ×1
compass-sass ×1
config ×1
data-binding ×1
directive ×1
jasmine ×1
node.js ×1
npm ×1
plugins ×1
rest ×1
susy-compass ×1
typescript ×1
vue-cli ×1
vuejs2 ×1
webpack ×1
yargs ×1