I am trying to make two tasks, a watch and build task.
The watch task calls my 'coffee' task wich compiles my .coffee files into javascript.
The build task should basically do the same, except that I wanna parse a boolean into the function, so that I can compile the code including source maps.
gulp = require 'gulp'
gutil = require 'gulp-util'
clean = require 'gulp-clean'
coffee = require 'gulp-coffee'
gulp.task 'clean', ->
gulp.src('./lib/*', read: false)
.pipe clean()
gulp.task 'coffee', (map) ->
gutil.log('sourceMap', map)
gulp.src('./src/*.coffee')
.pipe coffee({sourceMap: map}).on('error', gutil.log)
.pipe gulp.dest('./lib/')
# build app
gulp.task 'watch', ->
gulp.watch './src/*.coffee', ['coffee']
# build app
gulp.task 'build', ->
gulp.tasks.clean.fn()
gulp.tasks.coffee.fn(true)
# The default task (called when you run `gulp` from cli)
gulp.task 'default', ['clean', 'coffee', 'watch']
Does somebody have a solution for my problem? Am I doing something in principle wrong?
Thanks in advance.
The coffee task need not be a gulp task. Just make it a JavaScript function.
gulp = require 'gulp'
gutil = require 'gulp-util'
clean = require 'gulp-clean'
coffee = require 'gulp-coffee'
gulp.task 'clean', ->
gulp.src('./lib/*', read: false)
.pipe clean()
compile = (map) ->
gutil.log('sourceMap', map)
gulp.src('./src/*.coffee')
.pipe coffee({sourceMap: map}).on('error', gutil.log)
.pipe gulp.dest('./lib/')
# build app
gulp.task 'watch', ->
gulp.watch './src/*.coffee', =>
compile(false)
# build app
gulp.task 'build', ['clean'], ->
compile(true)
# The default task (called when you run `gulp` from cli)
gulp.task 'default', ['clean', 'build', 'watch']
Related
in our Scala project we're using Play Framework with some static assets in the public directory, linked in the normal way:
via "routes":
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
and in the "index.scala.hml":
<script type="text/javascript" src="#routes.Assets.versioned("javascripts/main.js")">
Now we want to use a submodule written in nodejs, which should create other js files on compiling, and put them to the assets folder.
We were able to run npm commands in the "build.sbt" file:
buildSubmodules := {
val s: TaskStreams = streams.value
val shell: Seq[String] = if (sys.props("os.name").contains("Windows")) Seq("cmd", "/c") else Seq("bash", "-c")
val npmInstall: Seq[String] = shell :+ "npm --prefix submodules/ install"
val npmBuild: Seq[String] = shell :+ "npm --prefix submodules/ run build"
s.log.info("building submodules...")
if((npmInstall #&& npmBuild !) == 0) {
s.log.success("submodules build successful!")
} else {
throw new IllegalStateException("submodules build failed!")
}
}
(Compile / compile) := ((Compile / compile) dependsOn buildSubmodules).value
and also included in the "index.scala.html":
<link rel="stylesheet" href="#routes.Assets.versioned("submodules/main.css")" />
but new created files still cannot be found in the "public/assets" folder after compilation finished.
Is there any way to add these assets to compiled project?
Thank you
I am trying to install Inno Setup 5 on the built in VS2017 agent on Azure Devops for one of my build pipelines but I am getting the following two lines in the stdout but it exits with a code of 1 and there is nothing in the log files. My question(s):
Does Inno Support being installed in this way?
What am I doing wrong?
Does chocolatey require being run on machine with a logged in GUI?
Here are the two lines from stdout that I think are most important
innosetup not installed. An error occurred during installation:
The process cannot access the file '...\.chocolateyPending' because it is being used by another process.
Here is my build pipeline on Azure Devops:
My installer script is written in javascript and executed via npm script after installing dependencies
const utils = require('./utils');
const fs = require('fs');
const path = require('path');
const spawn = require('child_process').spawn;
const command = 'cmd /c choco install innosetup --yes --force --no-progress -ia \'/VERYSILENT\'';
const logDirectory = path.join( 'C:', 'ProgramData', 'chocolatey', 'logs' );
function install() {
return new Promise( resolve => {
const cmd = command.split(' ').filter( ( x, i ) => i === 0 ).join('');
const args = command.split(' ').filter( ( x, i ) => i !== 0 );
var sqlcmd = spawn( cmd, args );
sqlcmd.stdout.on( 'data', data => {
console.log( data.toString().replace( /\r\n$/gmi, '' ) );
} )
sqlcmd.stderr.on( 'data', data => {
console.error( 'error', data.toString() );
process.exit( 1 );
} )
sqlcmd.on( 'exit', code => {
resolve( code );
} )
});
}
( async () => {
utils.header( 'installing Inno Setup' );
const installExitCode = await install();
utils.header( 'Log directory:', logDirectory );
console.log( ' *', fs.readdirSync( logDirectory ).join( '\r\n * ' ) );
utils.header( 'chocolatey.log' );
fs.createReadStream( path.join( logDirectory, 'chocolatey.log' ) ).pipe( process.stdout );
utils.header( 'choco.summary.log' );
fs.createReadStream( path.join( logDirectory, 'choco.summary.log' ) ).pipe( process.stdout );
if ( installExitCode !== 0 ) {
console.log( 'installer exited with error code:', installExitCode );
process.exit( installExitCode );
}
})();
Here is the stdout I am getting from the failed Azure Devops build:
2019-01-22T18:34:19.0336866Z ########################################
2019-01-22T18:34:19.0337014Z
2019-01-22T18:34:19.0337191Z installing Inno Setup
2019-01-22T18:34:19.0337335Z
2019-01-22T18:34:19.0337513Z Chocolatey v0.10.11
2019-01-22T18:34:19.0337798Z Installing the following packages:
2019-01-22T18:34:19.0338258Z innosetup
2019-01-22T18:34:19.0338554Z By installing you accept licenses for the packages.
2019-01-22T18:34:19.0338705Z
2019-01-22T18:34:19.0338856Z InnoSetup v5.6.1 (forced) [Approved]
2019-01-22T18:34:19.0339051Z innosetup package files install completed. Performing other installation steps.
2019-01-22T18:34:19.0339266Z innosetup not installed. An error occurred during installation:
2019-01-22T18:34:19.0339462Z Item has already been added. Key in dictionary: 'NPM_CONFIG_CACHE' Key being added: 'npm_config_cache'
2019-01-22T18:34:19.0339703Z The process cannot access the file 'C:\ProgramData\chocolatey\lib\InnoSetup\.chocolateyPending' because it is being used by another process.
2019-01-22T18:34:19.0339890Z
2019-01-22T18:34:19.0340054Z ########################################
2019-01-22T18:34:19.0340204Z
2019-01-22T18:34:19.0340364Z Log directory: C:\ProgramData\chocolatey\logs
2019-01-22T18:34:19.0340513Z
2019-01-22T18:34:19.0340775Z * choco.summary.log
2019-01-22T18:34:19.0342937Z * chocolatey.log
2019-01-22T18:34:19.0343090Z
2019-01-22T18:34:19.0343282Z ########################################
2019-01-22T18:34:19.0343425Z
2019-01-22T18:34:19.0343598Z chocolatey.log
2019-01-22T18:34:19.0343738Z
2019-01-22T18:34:19.0344018Z
2019-01-22T18:34:19.0344255Z ########################################
2019-01-22T18:34:19.0344406Z
2019-01-22T18:34:19.0344582Z choco.summary.log
2019-01-22T18:34:19.0344722Z
2019-01-22T18:34:19.0344902Z installer exited with error code: 1
To answer some of your direct questions...
Does Inno Support being installed in this way?
Yes, innosetup does support being installed this way. You can see that on the packages page here. That green bulb at the top of the page is an indication that this package version correctly installed via the automated processes that Chocolatey has, verifying that a package installed correctly.
Does chocolatey require being run on machine with a logged in GUI?
No, this is not necessary in most cases. There are some Chocolatey packages that don't install silently, and the mechanism used to install these "may" require the installation to be running in an actual User process, but the majority of packages don't need this.
What am I doing wrong?
I have a suspicion that "something" isn't working correctly when running through npm, and being installed within a Promise. Looking at the log, there seems to be this entry:
2019-01-22T18:34:19.0339462Z Item has already been added. Key in dictionary: 'NPM_CONFIG_CACHE' Key being added: 'npm_config_cache'
In the middle of the Chocolatey log, which doesn't make sense to me.
My best advice would be to use the standalone Chocolatey Task on this extension (NOTE: Full disclosure, I am the author of this extension), or, attempt to do the installation outside of npm, perhaps directly with a PowerShell Task.
Say you have a repo with this structure:
myrepo/project1
myrepo/project2
How do you configure buildbot so it only triggers build when there's update in myrepo/project1?
Following is sample config I have that triggers on the whole repo:
step_build = steps.ShellCommand(name='somebuildcommand',
command=['some', 'build', 'command'],
workdir="build/",
description='some build command')
factory = util.BuildFactory()
# check out the source
factory.addStep(steps.Git(repourl='https://github.com/some/myrepo.git', mode='incremental'))
factory.addStep(step_build)
c['builders'] = []
c['builders'].append(
util.BuilderConfig(name="runtests",
workernames=["example-worker"],
factory=factory))
Ok, figured this out myself, basically needed to configure scheduler and only trigger on "important" files, example below:
def file_is_important(change):
if not change.files:
return False
for file in change.files:
if file.startswith('important-dir/'):
print 'detected important changes:', change.files
return True
return False
c['schedulers'] = []
c['schedulers'].append(schedulers.SingleBranchScheduler(
name="all",
fileIsImportant=file_is_important,
change_filter=util.ChangeFilter(branch='master'),
treeStableTimer=None,
builderNames=["builder"]))
I started a project a couple of weeks ago and my gulpfile was working just fine. I have some time today so I thought I would continue working on my project, however I've noticed that all of my gulp files are not working. I'm not getting any errors and I looked over my file it appears to be fine. But, when I try to compile no css file is created. Below is my code. Can someone tell me what I'm doing wrong?
gulp = require('gulp')
jshint = require('gulp-jshint')
sass = require('gulp-sass')
concat = require('gulp-concat')
uglify = require('gulp-uglify')
rename = require('gulp-rename')
gulp.task 'lint', ->
gulp.src('js/*.js')
.pipe(jshint())
.pipe jshint.reporter('default')
gulp.task 'sass', ->
gulp.src('scss/*.scss')
.pipe(sass())
.pipe gulp.dest('dist/css')
gulp.task 'scripts', ->
gulp.src('js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe gulp.dest('dist')
gulp.task 'watch', ->
gulp.watch 'js/*.js', [
'lint'
'scripts'
]
gulp.watch 'scss/*.scss', [ 'sass' ]
return
gulp.task 'default', [
'lint'
'sass'
'scripts'
]
This is my folder structure:
When I compile I get no errors, but no CSS folder or file is created.
Wow simple path issue ... my gulp.src was wrong.
gulp.src('scss/*.scss')
should be ...
gulp.src('sass/*.scss')
I just start using Rake instead of Make for building my projects, and would like to use some kind of "task template" for automating the building.
Consider the following snippets:
task :test1 => ['1', '2']
task :test2 => ['3', '4']
Rake::Tasks.each do |task|
p task
p task.sources
end
The output is:
$ rake
<Rake::Task test1 => [1, 2]>
[]
<Rake::Task test2 => [3, 4]>
[]
My question is why task.sources is [], that is the prerequisites are missed? Thanks in advance.
The prerequisites of a task are accessed with task.prerequisites.
task.sources and task.sourceis only used for tasks that are built from a rule as described in the rdocs: http://ruby-doc.org/stdlib-2.1.2/libdoc/rake/rdoc/Rake/Task.html#method-i-source