I'm using gulp and gettext, all works well except when I have multiple .po files.
gulp.task('translations', function () {
return gulp.src('app/po/*.po')
.pipe($.gettext.compile())
.pipe($.rename('translations.js'))
.pipe(gulp.dest(dest));
});
I have three .po files: lang1.po, lang2.po and lang3.po, and I only get lang3.po in translations.js. I guess this task is overwriting things. Any suggestions how I can cat everything together into translations.js ?
What you are doing here is:
step 1: compile lang1.po, compile lang2.po, compile lang3.po
step 2: rename lang1.po to translations.js, rename lang2.po to translations.js, rename lang3.po to translations.js
Get the idea?
You probably want to concat instead (using gulp-concat).
gulp.task('translations', function () {
return gulp.src('app/po/*.po')
.pipe($.gettext.compile())
.pipe(concat('translations.js')))
.pipe(gulp.dest(dest));
});
Hope that helps.
Related
i have so many line just like this json code (120000 lines)
{
"name":"V83.9",
"name":"Work",
"name":"V83.9",
"name":"Education",
"name":"V83.9",
"name":"Profession"
}
and i want this convert just like this
{
"name":"V83.9",
"name":"Work",
"name":"Education",
"name":"Profession"
}
and i wrote regex on vscode just like this but this is not working
Find: {\n"name":"$1",\n"name":"$2",\n"name":"$1",\n"name":"$3",\n"name":"$1",\n"name":"$4"\n}
Replace: {\n"name":"$1",\n"name":"$2",\n"name":"$3",\n"name":"$4"\n}
How do i do this?
Please check the Transformer extension, where i have applied it on your example and it works:
I'm trying to create a report for my scenario, I want to execute some validations and add the retults in a string, then, write this string in a TXT file (for each validation I would like to add the result and execute again till the last item), something like this:
it ("Perform the loop to search for different strings", function()
{
browser.waitForAngularEnabled(false);
browser.get("http://WebSite.es");
//strings[] contains 57 strings inside the json file
for (var i = 0; i == jsonfile.strings.length ; ++i)
{
var valuetoInput = json.Strings[i];
var writeInFile;
browser.wait;
httpGet("http://website.es/search/offers/list/"+valuetoInput+"?page=1&pages=3&limit=20").then(function(result) {
writeInFile = writeInFile + "Validation for String: "+ json.Strings[i] + " Results is: " + expect(result.statusCode).toBe(200) + "\n";
});
if (i == jsonfile.strings.length)
{
console.log("Executions finished");
var fs = require('fs');
var outputFilename = "Output.txt";
fs.writeFile(outputFilename, "Validation of Get requests with each string:\n " + writeInFile, function(err) {
if(err)
{
console.log(err);
}
else {
console.log("File saved to " + outputFilename);
}
});
}
};
});
But when I check my file I only get the first row writen in the way I want and nothing else, could you please let me know what am I doing wrong?
*The validation works properly in the screen for each of string in my file used as data base
**I'm a newbie with protractor
Thank you a lot!!
writeFile documentation
Asynchronously writes data to a file, replacing the file if it already
exists
You are overwriting the file every time, which is why it only has 1 line.
The easiest way would probably (my opinion) be appendFile. It writes to a file without overwriting existing data and will also create the file if it doesnt exist in the first place.
You could also re-read that log file, store that data in a variable, and re-write to that file with the old AND new data included in it. You could also create a writeStream etc.
There are quite a few ways to go about it and plenty of other answers
on SO specifically on those functions that can provide more info.
Node.js Write a line into a .txt file
Node.js read and write file lines
Final note, if you are using Jasmine you can also create a custom jasmine reporter. They have methods that contain exactly what you want (status Pass/Fail, actual vs expected values etc) and it's fairly easy to set up with Protractor
I'm using the config from my project but would like to run karma just for one specific test script one time. I don't want to have to create a whole new config file just for this case and would prefer just passing in the script I want run (so basically telling karma to use files: ['myTest.js'].
But there don't seem to be any options for that AFAICT in the docs. Why would this be missing? It seems like a fundamental feature IMO.
in karma.conf something like that:
function mergeFilesWithArgv(staticFiles) {
var source = staticFiles, argv = process.argv;
argv.forEach(function (arg) {
var index = arg.indexOf('--check=');
if (index !== -1) {
source.push(arg.substring(8));
}
});
return source;
}
config.set({
...
files: mergeFilesWithArgv([
'js_src/tests/*.test.js'
]),
...
});
use: karma start --check='./path/to/file.js'
or for multiple files: karma start --check='./path/to/file.js' --check='/another/path/to/another/file.js'
I'm using Gradle build to compile Java.
During the build, I get successful build deliverables BUT I want to add some extra files which are just the copy or rename of some files which exist within the built ".war" file by Gradle build.
The following code is what I'm using. What I'm trying to do is:
1. unwar a .war file in a build/tmp/warApplication folder
2. copy/rename a file i.e. oldname-1.2.3 to newname-1.2.3
3. copy/rename oldname.war.properties file to newname.war.properties
4. copy/rename oldname.jar.properties file to newname.jar.properties
5. war all data inside build/tmp/warApplication folder and create original .war file (which is projectname.war)
Issue:
1. After unwar step is complete, I see under tmp/warApplication folder, all files in the tree have valid file size.
2. warApplication.doLast - works i.e. it doesn't give any error mesg.
3. Once all copy/rename steps are complete, I see the file size under tmp/warApplication folder tree or subtree level is now 0 bytes in size.
WHAT am I missing? How can I copy a file A of size X bytes to file B of same X bytes.
// add a few extra files
warApplication.doLast {
def tempWarDirU = new File("${buildDir}/tmp/warApplication")
tempWarDirU.mkdirs()
ant.unwar(src: "${buildDir}/thidsWar/${thidsProjectName}.war",
dest: "${buildDir}/tmp/warApplication")
println ""
println "--- Inside warApplication - last stage ---"
println ""
copy {
from "${buildDir}/tmp/warApplication"
into "${buildDir}/tmp/warApplication"
rename (/([a-z]+)-([0-9]+\.[0-9]+.+)/, 'newname-$2')
}
copy {
from "${buildDir}/tmp/warApplication/WEB-INF/classes"
into "${buildDir}/tmp/warApplication/WEB-INF/classes"
rename (/([a-z]+)\.war\.([a-z]+)/, 'newname.war.$2')
}
copy {
from "${buildDir}/tmp/warApplication/WEB-INF/classes"
into "${buildDir}/tmp/warApplication/WEB-INF/classes"
rename (/([a-z]+)\.jar\.([a-z]+)/, 'newname.jar.$2')
}
ant.jar ( update: "true", destfile: "${buildDir}/thidsWar/${thidsProjectName}_1.war") {
fileset(dir: "${buildDir}/tmp/warApplication",includes: '*/**')
}
println ""
println ""
}
An easier solution would be, thanks to Pete N.
task renABCToXYZ {
doLast {
file("ABC").renameTo(file("XYZ"))
}
}
Had to mention the "include" section. without that, it'was copying all files into 0 bytes in the tree.
copy {
from "${buildDir}/tmp/warApplication"
into "${buildDir}/tmp/warApplication"
include "${thidsProjectName}-$project.version"
rename (/([a-z]+)-([0-9]+\.[0-9]+.+)/, 'newname-$2')
}
copy {
from "${buildDir}/tmp/warApplication/WEB-INF/classes"
into "${buildDir}/tmp/warApplication/WEB-INF/classes"
include "${thidsProjectName}.war.properties"
rename (/([a-z]+)\.war\.([a-z]+)/, 'newname.war.$2')
}
copy {
from "${buildDir}/tmp/warApplication/WEB-INF/classes"
into "${buildDir}/tmp/warApplication/WEB-INF/classes"
include "${thidsProjectName}.jar.properties"
rename (/([a-z]+)\.jar\.([a-z]+)/, 'newname.jar.$2')
}
I just generated the .cs file using codeDom. Can someone explain how do I execute it?
The code below will allow you to compile the code using the codedom and then you can show the user if the code compiled correctly or not. It even creates a DLL as well.
Thanks
Alex
// Store provider from the method into a object, Default is CSharpCodeProvider**
CodeDomProvider provider = this.GetCurrentProvider();
// Configure a CompilerParameters that links System.dll**
String[] referenceAssemblies = { "System.dll", "System.Data.Linq.dll", "System.Web.dll","System.XML.dll","System.ComponentModel.DataAnnotations.dll", "System.Data.dll", _mvcLocation };
CompilerParameters cp = new CompilerParameters(referenceAssemblies, this.fileLocation + this.fileName + ".dll", false);
// Generate an executable rather than a DLL file.**
cp.GenerateExecutable = true;
// Invoke compilation.**
CompilerResults _results = provider.CompileAssemblyFromFile(cp, this.fileLocation + this.fileName + "." + this.extention);
It's not quite that simple. See here for a primer. Basically the CodeDom supports scenarios such as code generation and dynamic compilation. So .cs files created with the CodeDom are not executables in the usual sense.