Tag: 吞咽

我如何将自定义数据传递给我的摩卡testing?

我们正在使用酱汁实验室进行跨平台/跨浏览器testing。 你可以在这个要点find我的testing套件(以节省这个问题的空间): https : //gist.github.com/chevex/397a5a18a1a386897b41 问题是,我能弄清楚如何将自定义数据传递给testing套件的唯一方法是通过一个环境variables 。 因此,当我的gulp任务试图并行运行testing套件对多个目标时,它们最终都会针对同一个目标运行,因为循环完成迭代,并且process.env.SAUCE_TARGET被设置为第一个套房甚至运行。 var gulp = require('gulp'); var gulpMocha = require('gulp-mocha'); var mergeStream = require('merge-stream'); gulp.task('sauce-tests', function () { var targets = ['chrome', 'firefox', 'internet explorer']; var streams = targets.map(function (target) { process.env.SAUCE_TARGET = target; return gulp.src('./test/sauce-tests.js', {read:false}) .pipe(gulpMocha({ reporter: 'spec' }); }); return mergeStream.apply(null, streams); }); forEach提供的闭包没有帮助,因为它在每次迭代中设置一个基本上全局的值( process.env.SAUCE_TARGET )。 […]

使用Gulp将资产上传到s3

我目前正尝试使用aws-sdk和gulp将网站的资源上传到amazon s3,但是现在我只是使用以下代码实现了上传单个文件: gulp.task('publish', function() { var AWS = require('aws-sdk'), fs = require('fs'); AWS.config.accessKeyId = 'access_id'; AWS.config.secretAccessKey = 'secret_key'; AWS.config.region = 'eu-central-1'; var fileStream = fs.createReadStream('folder/filename'); fileStream.on('error', function (err) { if (err) { throw err; } }); fileStream.on('open', function () { var s3 = new AWS.S3(); s3.putObject({ Bucket: 'bucket_name', Key: 'assets/filename', Body: fileStream, ACL:'public-read' }, function […]

angular度2多次错误TS2300:重复的标识符

系统configuration Ubuntu 14.04 节点-v => v5.6.0 npm -v => 3.7.1 typings最新版本(不知道如何获得版本细节) 而我的文件夹样本/服务器结构第一次使用angular2时下面 |– server.js |– server.ts |– tsconfig.json |– typings | |– browser | | `– ambient | | |– express | | | `– express.d.ts | | |– mime | | | `– mime.d.ts | | |– node | | | `– node.d.ts | […]

gulp-foreach没有遍历所有文件

我有一个非常基本的使用方法,那就是我一直在做错事; 我只是(现在)试图打印在gulp.src中find的所有文件。 当用gulp-foreach做这件事时,只有非常非常小的文件样本被打印出来 – 大约有数百个中的15个。 当使用gulp-print的东西按预期工作。 const gulp = require('gulp'), foreach = require('gulp-foreach'), gulpPrint = require('gulp-print'); gulp.src([`../../**/*.js`].concat([])) .pipe(gulpPrint(path => { console.log(path); })) .pipe(foreach((stream, file) => { console.log(file.path); return stream; })) 与foreach的代码被触发大约15次,与gulpPrint交错,然后是单独的大量gulpPrint声明。 如果我注释掉gulpPrint部分, foreach打印大约15次,然后退出,并且按照预期, gulpPrint单独发现每个find的文件,并将其泛滥。 我可以使用gulp-print ,但我想知道我在做什么错误的gulp-foreach 。

作为交互式提示运行gulp

运行Gulp任务需要花费大量时间,例如: 加载吞咽任务; 导入节点模块。 这可以优化,而不是每次运行gulp task_name我们将运行的东西,将加载gulpfile.js并开始提示,我们可以通过input其名称运行gulpfile.js任务。 这将允许花费时间加载吞吐任务一次,并且导入的节点模块将通过require被caching,并且在随后的任务执行中加载更快。 这怎么能被执行? 这是自我回答的问题,我与社区分享我的知识。 其他答案是欢迎的。 最好的答案将被接受。

$ http Post上的Angularjs – 500(内部服务器错误)

我是离子和angular的新手。 我正在使用angular.js构build带ionic framework的示例。 我想通过$ http post方法调用WebApi。 我检查了这个( 离子代理的例子 )解决scheme,我试图用我的api实现相同的。 当我在示例项目中调用上述示例中提供的api时,我得到的logging,但它不与我的api工作。 它会引发500个内部错误。 这是我的app.js angular.module('myApp', ['myApp.controllers', 'myApp.services']) .constant('ApiEndpoint', {url: 'http://localhost:8100/api'}) Services.js angular.module('myApp.services', []) .factory('Api', function($http, $q, ApiEndpoint) { console.log('ApiEndpoint', ApiEndpoint) var getApiData = function() { var q = $q.defer(); var data = { Gameweek_ID: '179', Vender_ID: '1', Language:'en' }; var config = { headers : { "Content-Type": […]

使用gulp-imgmin不止一次压缩或缩小图像是不好的?

我试图决定是否应该只压缩/缩小所有图像,并让它们相互覆盖,或者是否应将每个图像的缩小/压缩版本存储在单独的文件夹中? 继续压缩已压缩的图像会不好吗?

pipe道将Gulpstream文件的内容连接到服务器(connect,express或http)响应

我怀疑这是来自对stream的有限理解,但是我已经到处寻找,并且无法工作。 简而言之,我想要一个Gulpstream,并将stream的串联内容直接传递给一个快速响应, 而无需写入文件系统。 这是我的想法(工作正常): app.get('*', function(req, res){ var stream = fs.createReadStream(__dirname + '/app/index.html'); stream.pipe(res); }); 但是我想用一个Gulpstream应用相同的概念: app.get('/app/js/concatenated-js-files.js', function(req, res){ gulp.src('app/js/**/*.js') .pipe(concat()) .pipe(res); }); app.listen(5555, function() { console.log('Listening on port 5555'); }); 从浏览器请求/app/js/concatenated-js-files.js时不起作用并产生以下结果: [gulp] Error in plugin 'gulp-concat': Missing fileName option for gulp-concat at module.exports (/Users/lgomez/Projects/index-packager/node_modules/gulp-concat/index.js:10:24) at Object.handle (/Users/lgomez/Projects/index-packager/index.js:83:15) at next_layer (/Users/lgomez/Projects/index-packager/node_modules/express/lib/router/route.js:103:13) at Route.dispatch (/Users/lgomez/Projects/index-packager/node_modules/express/lib/router/route.js:107:5) at […]

Gulp – 重新编译标记的颠簸版本

关于我使用gulp-tag-version的问题 ,自述文件中提出: function inc(importance) { // get all the files to bump version in return gulp.src(['./package.json', './bower.json']) // bump the version number in those files .pipe(bump({type: importance})) // save it back to filesystem .pipe(gulp.dest('./')) /* Recompile the Javascript here */ // commit the changed version number .pipe(git.commit('bumps package version')) // read only one file to […]

错误:无法find模块'扳手',我得到这个错误,当我运行gulp命令

我在本地和全球都安装了npm,bower和gulp。但是当我在该文件夹中运行gulp时,出现了这个错误。 Error: Cannot find module 'wrench' at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/home/myPC/documents/workspace/frontend/gulpfile.js:10:14) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) 这是我的gulpfile.js 'use strict'; var gulp = require('gulp'); var wrench = require('wrench'); wrench.readdirSyncRecursive('./gulp').filter(function (file) { return (/\.(js|coffee)$/i).test(file); […]