I'm using gulp-newer on my project to check which html file have been updating, and to prevent the reload of every html file in the project.
Everything is working fine except the partial files.
If I edit something in a partial the file will be update correctly but the file in which I call the partial won't be update.
I saw that there is an options.extra with gulp-newer but can't make this work.
My idea is to reload every html files if I update something in one of the partials, and keep the single file reload if I work on a basic file.
Here my task:
// COMPILE SLIM TO HTML
// ---------------------------------------------------------
gulp.task('slim', function () {
return gulp.src(slim_dev + '/**/*.slim')
// prevent server from crashing
.pipe(plugins.plumber({ errorHandler: function(err) {
plugins.notify.onError({
title: "Gulp error in " + err.plugin
})(err);
}}))
// compile slim to html
.pipe(plugins.slim({
pretty: false,
include: true
}))
.pipe(plugins.newer('build/views/'))
// minify html
.pipe(plugins.minifyHtml())
// copy result to build folder
.pipe(gulp.dest(slim_build))
// reload server on slim save
.pipe(stream({once:true}))
// notify when task completed
.pipe(plugins.notify('Slim compilation completed !'));
});
Related
below is the code i am using to validate that download made it to the downloads folder.
The file is of csv format. filepath is declared at the top.
the test passes but the command log outputs the entire content from the file for both the assertions(should and contains). how do i suppress the command log from outputting the entire body from the file. i already tried passing the false flag and it still outputs everything.
using cypress version 9.2
it('verify download',() => {
// some code here to fill in the form data and initiate download
cy.readFile(filepath,{
log : false
}).should('exist').and('contains',"some text to assert")
})
I've set up a very small browser project using create-js-app. I try to load a file called test.txt located in my src directory.
Following is the content of my main.js:
import * as THREE from 'three';
const loader = new THREE.FileLoader();
loader.load(
"test.txt",
function (data) {
console.log(data);
},
function (xhr) {
console.log(
"Loading file : " +
(xhr.loaded / xhr.total) * 100 +
"% loaded"
);
},
function (err) {
console.error(err);
}
);
When running my site in Chrome, I get the content of my index.html file instead of test.txt. I spent some time trying to understand this with no success.
I get this result no matter which file path I specify as first argument of loader.load(), I can even specify a file that is not existing.
Has anybody already faced this issue?
Thanks a lot.
Edit: I'm using Parcel as the bundler.
This issue comes down to internal details of create-js-app, and different web applications may host static resources (i.e. images and other assets that are not compiled source code) in different ways. But generally speaking, the src/ directory is not hosted/deployed/served on the website. If your application has the structure shown here then you probably want to put the .txt file into the public/ directory instead.
Requesting any file that cannot be found at the given URL might be giving you the index page instead, depending on how your site is set up by create-js-app.
I'm updating the answer above: I'm using Parcel. I fixed my project by adding this line:
url = require('test.txt')
The require function makes the browser import the txt file, and it returns the hashed url of the stored file. All I had to do next was to call
loader.load(url, ... )
I have an Angular template created by ASP.NET Boilerplate. I have published it successfully and it is running smoothly on IIS under a website. My client, however, wants to have it run under a Virtual Directory rather than a website for itself.
I have updated the appconfig.json as below:
{
"remoteServiceBaseUrl": "http://localhost:8080/Training",
"appBaseUrl": "http://localhost:8080/Training"
}
and did the same with App in the appSettings.json:
"App": {
"ServerRootAddress": "http://localhost:8080/Training/",
"ClientRootAddress": "http://localhost:8080/Training/",
"CorsOrigins": "http://localhost:8080/Training"
}
For some reason, when I run the app, I get the following errors that it cannot load some CSS and JavaScript bundles:
I have manually changed the index.html in the wwwroot folder and added http://localhost:8080/Training/ to the beginning of each href. By doing that, all those errors have gone and now I am left with this error:
GET http://localhost:8080/assets/appconfig.json 404 (Not Found)
Which I think is related to the AppPreBootstrap.ts file, where it reads from the appconfig.json file.
Do I have to make any changes in the application settings somewhere, before publishing it, to get rid of the above issues?
Ensure that appRootUrl ends with '/' in AppPreBootstrap.ts:
private static getApplicationConfig(appRootUrl: string, callback: () => void) {
appRootUrl += appRootUrl.endsWith('/') ? '' : '/'; // Add this line
return abp.ajax({
url: appRootUrl + 'assets/' + environment.appConfig,
// ...
}).done(result => {
// ...
});
}
I am running unit tests using QUnit and trying to integrate QUnit into our build automation and Continuous Integration process. For Atlassian Bamboo to parse the test output it requires the test output to be in an xml file. I can generate a console log that is in the required xml format by using the qunit-reporter-junit plugin. When Gulp-QUnit runs our test-runner.html file it outputs the console.log to the screen. My problem is that I cannot find a way to pipe this console.log output into a file.
I have tried the following approaches:
Using gulp-log-capture plugin (does nothing):
gulp.task('qunit', function() {
return gulp.src('./qunit/test-runner.html')
.pipe(logCapture.start(console,'log'))
.pipe(qunit())
.pipe(logCapture.stop('build.xml'));
});
Piping the output into a write stream (which throws an error):
gulp.task('qunit', function() {
return gulp.src('./qunit/test-runner.html')
.pipe(qunit())
.pipe(fs.createWriteStream('build.xml));
});
Using gulp-out plugin (which simply pipes the input html into the new file):
gulp.task('qunit', function() {
return gulp.src('./qunit/test-runner.html')
.pipe(qunit())
.pipe(out('build.xml');
});
The XML is right there on the screen I just need to get it into a file somehow.
It turns out that phantom js takes node-like scripts that will run on execution. I basically took the run-qunit script from the examples directory of phantom-js and adjusted it to pipe console output into a build.xml file. Example script can be found here: https://github.com/ariya/phantomjs/blob/master/examples/run-qunit.js
I simply adjusted the onConsoleMessage listener (ln48) like so:
page.onConsoleMessage = function(msg) {
if( msg.search(/xml/) > -1 ) {
fs.write('build.xml',msg);
}
console.log(msg);
};
To make this run as part of an automated build process, in Gulp I run the following task using the exec plugin.
exec = require('child_process').exec;
.
.
.
gulp.task('phantom',function() {
exec('phantomjs ./qunit/run-qunit.js ./qunit/test-runner.html');
});
Both of these adjustments successfully create a build.xml file that Atlassian Bamboo can read as part of its process.
I am using meteor to create simple blog system. For sitemaps files I'm using this package.
I added some initialize data in server startup function (create some post) and used below code (server/sitemaps.js) in server to create sitemaps for each category (e.g. sitemap1.xml for first category and etc):
function sitemapOutput(categoryName){
var out = [], posts = Posts.find({ category: categoryName }).fetch();
_.each(posts, function(post) {
out.push({
page: post.url(),
lastmod: post.insertDate,
changefreq: 'weekly'
});
});
return out;
}
Categories.find().forEach(function(Category, index) {
sitemaps.add('/sitemap' + (index+1) +'.xml',
function(){ return sitemapOutput(Category.name); });
});
And I have startup like this: (server/startup.js)
Meteor.startup(function () {
// some post and category created here
});
But sitemaps didn't exist until server restart (my robots.txt files also empty) but when server restarted sitemaps and robots.txt content created for me.
I think posts inserted after sitemaps.js but what's the problem guys and how to fix that?
New try:
I try new solution like below but this code also didn't work. (I want to create seperate sitemap file for each 10000 category to prevent big sitemap and google sitemap error):
for (var i=0;i<=Math.round(Categories.find().count()/10000);i++) {
sitemaps.add('/sitemap' + i +'.xml', function(){
var out = [];
Categories.find({}, {sort: {insertDate: 1} ,limit: 10000, skip: i * 10000}).forEach(function(Category) {
out.push({
page: "/category/" + Category.title + "/" + Category._id,
lastmod: Category.insertDate,
changefreq: 'weekly'
});
});
return out;
});
}
robots.txt show sitemap files correctly but all sitemap is empty like this:
<urlset> </urlset>
When does sitemaps.add() run? I think it does on server restart but New try was disappointed me and I think my guess is incorrect and If sitemaps.add() was run why it's empty.
Your problem seems to be the folder structure. You said you have /server/sitemaps.js and /server/startup.js and you wish that sitemaps would run after your startup, but the thing is Meteor will run those files alphabetically, so sitemap comes before startup. If you place your startup.js inside a lib folder, such as /server/lib/startup.js, you'll get the desired results, because Meteor will run lib folder before others.
It's normal behavior, the code at Meteor.startup will run just once at app start. If you're looking to re run this function you either need to use meteor method to call the function from the client or you can you use something like cron job to run repeat jobs here is a great package https://atmospherejs.com/percolate/synced-cron