Can I increase maxBuffer for gruntjs task grunt-svn-export - gruntjs

The grunt task svn-export runs into an Error:
Running "svn_export:dev" (svn_export) task
Exporting from http://path.to/repo
>> #svn export http://path.to/repo target
>> Error: stdout maxBuffer exceeded.
The task configuration is:
svn_export: {
dev: {
options: {
repository: 'http://path.to/repo',
output: 'target'
}
}
}
Is it possible to increase nodejs maxBuffer for a specific gruntjs task?

Related

Jenkins - Symfony with environment variables

I've been struggling in building automated build using Jenkins with symfony 3.4.
How to properly set environment variables in Jenkins that symfony can find it.
here's my pipeline.
node {
def app
stage('composer install') {
sh 'export $(cat env/env_vars | xargs)'
sh 'composer install --optimize-autoloader'
}
stage('yarn install') {
sh 'yarn install'
}
stage ('build assets') {
sh 'yarn encore production'
}
stage('Clone repository') {
// clone
}
stage('Build image') {
// build here
}
stage('Push image') {
// push here
}
}
then after I run my build.
I always got this message
....
Creating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
database_host ('%env(DATABASE_HOST)%'): Script Incenteev\ParameterHandler
\ScriptHandler::buildParameters handling the symfony-scripts event terminated with an exception
[Symfony\Component\Console\Exception\RuntimeException]
Aborted
....
I already used some jenkins plugin like EnvInjector and something similar. But still symfony can't find my environment variables.
You can probably solve this like this:
stage('composer install') {
sh 'export $(cat env/env_vars | xargs) && composer install --optimize-autoloader'
}
This will make the environment variables available in the same shell session.

Unable to compile Bootstrap css using grunt

There are plenty of tutorials online for this, but after two days of struggle - I have to get some assistance.
I am trying to to add a namespace to Bootstrap so I can use it in Salesforce without interfering with Salesforce's stylesheet.
My goal is to wrap the bootstrap.less with .bs{} so I may refer to it on my page as a resource.
It seems that no matter what, the bootstrap.css isn't compiling.
Bootstrap Test v2
├───bootstrap-3.3.7
├───Gruntfile.js
|───dist
| |───css
| |───bootstrap.css
|───less
|───bootstrap.less
Steps to reproduce:
1) Modify bootstrap.less (wrap content with .bs{})
2) Navigate to Bootstrap Test V2
3) run command 'grunt dist'
output:
C:\Users\json\Desktop\Bootstrap\Bootstrap Test v2>grunt dist
(node:8444) ExperimentalWarning: The http2 module is an experimental API.
Running "clean:dist" (clean) task
>> 1 path cleaned.
Running "less:compileCore" (less) task
>> 1 stylesheet created.
>> 1 sourcemap created.
Running "less:compileTheme" (less) task
>> 1 stylesheet created.
>> 1 sourcemap created.
Running "autoprefixer:core" (autoprefixer) task
>> 1 autoprefixed stylesheet created.
>> 1 sourcemap created.
Running "autoprefixer:theme" (autoprefixer) task
>> 1 autoprefixed stylesheet created.
>> 1 sourcemap created.
Running "csscomb:dist" (csscomb) task
>> Using custom config file "less/.csscomb.json"...
>> Sorting file "dist/css/bootstrap-theme.css"...
>> Sorting file "dist/css/bootstrap.css"...
Running "cssmin:minifyCore" (cssmin) task
>> 1 sourcemap created.
>> 1 file created. 146.01 kB → 121.2 kB
Running "cssmin:minifyTheme" (cssmin) task
>> 1 sourcemap created.
>> 1 file created. 26.13 kB → 23.41 kB
Running "copy:fonts" (copy) task
Created 1 directory, copied 5 files
Running "concat:bootstrap" (concat) task
Running "uglify:core" (uglify) task
File dist/js/bootstrap.min.js created: 69.71 kB → 37.05 kB
>> 1 file created.
Running "commonjs" task
File dist/js/npm.js created.
Done.
Execution Time (2018-05-23 23:58:31 UTC+3)
clean:dist 77ms █ 2%
less:compileCore 994ms ███████████ 25%
less:compileTheme 146ms ██ 4%
autoprefixer:core 538ms ██████ 14%
autoprefixer:theme 90ms █ 2%
csscomb:dist 1.1s ████████████ 28%
cssmin:minifyCore 421ms █████ 11%
cssmin:minifyTheme 53ms █ 1%
copy:fonts 48ms █ 1%
uglify:core 427ms █████ 11%
Total 3.9s
gruntfile:
module.exports = function(grunt) {
require('jit-grunt')(grunt);
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"dist/css/bootstraptest.css": "less/bootstrap.less" // destination file and source file
}
}
},
watch: {
styles: {
files: ['less/**/*.less'], // which files to watch
tasks: ['less'],
options: {
nospawn: true
}
}
}
});
grunt.registerTask('default', ['less', 'watch']);
};
module.exports = function(grunt) {
grunt.initConfig({
less: {
development: {
options: {
paths: ["assets/css"]
},
files: {"dist/css/bootstrap.css": "less/bootstrap.less"}
},
production: {
options: {
paths: ["assets/css"],
cleancss: true
},
files: {"dist/css/bootstrap.css": "less/bootstrap.less"}
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', ['less']);
};
Notes:
1) Using the 'grunt' command isn't working for me, it throws an error 'Running "jekyll:docs" (jekyll) task' and suggest to download jekyll which I already have installed. I have read online that 'grunt dist' should be sufficient - is it correct?
Using the 'node js command line' instead of the regular command line did the trick for me.
Windoes: Start > Node.js command prompt
I followed the steps in this article and it finally worked.

Task not found when grunt is run using load-grunt-config

I am learning Grunt and want to use load-grunt-config to start with. Here is my code :
Gruntfile.js
module.exports = function (grunt){
var path = require('path');
require('load-grunt-config')(grunt, {
configPath: path.join(process.cwd(), 'grunt-tasks'),
});
grunt.registerTask('install',['test']);
};
I have grunt-tasks folder in root directory of my project along with Gruntfile.js and in that I have included test.js
test.js
module.exports = {
test :{
local : {
}
}
};
Now when I say grunt install from command line and using CWD as my project's root directory I get following error :
Warning: Task "test" not found. Use --force to continue.
and when I include following segment in Gruntfile.js
loadGruntTasks : {
pattern : '*'
}
I get following error :
>> Local Npm module "load-grunt-config" not found. Is it installed?
Warning: Task "test" not found. Use --force to continue.
May I know what I don't understand here?

gruntjs: how to move a file out of the way

I need to move a file out of the way before one of my Grunt tasks run, and then put it back after the task has completed.
How do I do this with GruntJS?
Basically I want to run this command:
# move node-webkit out of the way
mv app/node-webkit ./tmp
# run grunt task
# move node-webkit back
mv ./tmp/node-webkit ./app/
Yeah, have a look at grunt-shell. In your init config:
shell: {
move: {
command: 'mv app/node-webkit ./tmp'
},
moveback: {
command: 'mv ./tmp/node-webkit ./app/'
}
}
Then, register a function that runs the move command before the other tasks you want to run, then run the moveback task.
module.exports = function(grunt) {
'use strict';
grunt.registerTask('mytask', [
'shell:move',
'othertaskshere',
'shell:moveback'
]);
};

How to get grunt task name given on command line?

In order to customize my grunt tasks, I need access to the grunt task name given on the command line when starting grunt.
The options is no problem, since its well documented (grunt.options).
It's also well documented how to find out the task name, when running a grunt task.
But I need access to the task name before.
Eg, the user writes
grunt build --target=client
When configuring the grunt job in my Gruntfile.js, I can use
grunt.option('target') to get 'client'.
But how do I get hold of parameter build before the task build starts?
Any guidance is much appreciated!
Your grunt file is basically just a function. Try adding this line to the top:
module.exports = function( grunt ) {
/*==> */ console.log(grunt.option('target'));
/*==> */ console.log(grunt.cli.tasks);
// Add your pre task code here...
Running with grunt build --target=client should give you the output:
client
[ 'build' ]
At that point, you can run any code you need to before your task is run including setting values with new dependencies.
A better way is to use grunt.task.current which has information about the currently running task, including a name property. Within a task, the context (i.e. this) is the same object. So . . .
grunt.registerTask('foo', 'Foobar all the things', function() {
console.log(grunt.task.current.name); // foo
console.log(this.name); // foo
console.log(this === grunt.task.current); // true
});
If build is an alias to other tasks and you just want to know what command was typed that led to the current task execution, I typically use process.argv[2]. If you examine process.argv, you'll see that argv[0] is node (because grunt is a node process), argv[1] is grunt, and argv[2] is the actual grunt task (followed by any params in the remainder of argv).
EDIT:
Example output from console.log(grunt.task.current) on grunt#0.4.5 from within a task (can't have a current task from not a current task).
{
nameArgs: 'server:dev',
name: 'server',
args: [],
flags: {},
async: [Function],
errorCount: [Getter],
requires: [Function],
requiresConfig: [Function],
options: [Function],
target: 'dev',
data: { options: { debugPort: 5858, cwd: 'server' } },
files: [],
filesSrc: [Getter]
}
You can use grunt.util.hooker.hook for this.
Example (part of Gruntfile.coffee):
grunt.util.hooker.hook grunt.task, (opt) ->
if grunt.task.current and grunt.task.current.nameArgs
console.log "Task to run: " + grunt.task.current.nameArgs
CMD:
C:\some_dir>grunt concat --cmp my_cmp
Task to run: concat
Running "concat:coffee" (concat) task
Task to run: concat:coffee
File "core.coffee" created.
Done, without errors.
There is also a hack that I've used to prevent certain task execution:
grunt.util.hooker.hook grunt.task, (opt) ->
if grunt.task.current and grunt.task.current.nameArgs
console.log "Task to run: " + grunt.task.current.nameArgs
if grunt.task.current.nameArgs is "<some task you don't want user to run>"
console.log "Ooooh, not <doing smth> today :("
exit() # Not valid. Don't know how to exit :), but will stop grunt anyway
CMD, when allowed:
C:\some_dir>grunt concat:coffee --cmp my_cmp
Running "concat:coffee" (concat) task
Task to run: concat:coffee
File "core.coffee" created.
Done, without errors.
CMD, when prevented:
C:\some_dir>grunt concat:coffee --cmp my_cmp
Running "concat:coffee" (concat) task
Task to run: concat:coffee
Ooooh, not concating today :(
Warning: exit is not defined Use --force to continue.
Aborted due to warnings.

Resources