Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).catch(function(e) {
if (++attempts >= numAttempts) {
// reject with the last error
reject(e);
}
else {
setTimeout(attempt, interval);
}
});
}
});
}
var onTravis = !!process.env.TRAVIS;
HttpServer.createServer({
showDir: false,
autoIndex: false,
root: './',
}).listen(8000, '127.0.0.1');
var browserConfig = {version : 'latest'};
if (onTravis) {
var UA_VERSION = process.env.UA_VERSION;
if (UA_VERSION) {
browserConfig.version = UA_VERSION;
}
var UA = process.env.UA;
if (!UA) {
throw new Error('No test browser name.')
}
'use strict'
const httpServer = require('http-server');
// default cache disabled
let cache = -1;
if (process.env.NODE_ENV === 'production') {
cache = 3600;
const msg = 'Running in production mode (caching is enabled)';
console.log(msg);
}
const server = httpServer.createServer({
root: './',
cache: cache,
robots: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true'
}
});
require('chokidar-socket-emitter')({app: server.server});
server.listen(8888);
console.log('Started http-server with chokidar-socket-emitter');
console.log('Running on localhost:8888');
gulp.task('simpleserver', function(cb) {
httpServer.createServer({ root: './', cache: 5 }).listen(4000);
// httpServer.createServer({ root: './', cache: 5 }).listen(8088);
console.log('Server address: http://127.0.0.1:4000/');
});
test('global build --target lib', async () => {
const { stdout } = await execa(binPath, ['build', 'testLib.vue', '--target', 'lib'], { cwd })
expect(stdout).toMatch('Build complete.')
const distDir = path.join(cwd, 'dist')
const hasFile = file => fs.existsSync(path.join(distDir, file))
expect(hasFile('demo.html')).toBe(true)
expect(hasFile('testLib.common.js')).toBe(true)
expect(hasFile('testLib.umd.js')).toBe(true)
expect(hasFile('testLib.umd.min.js')).toBe(true)
expect(hasFile('testLib.css')).toBe(true)
const port = await portfinder.getPortPromise()
server = createServer({ root: distDir })
await new Promise((resolve, reject) => {
server.listen(port, err => {
if (err) return reject(err)
resolve()
})
})
const launched = await launchPuppeteer(`http://localhost:${port}/demo.html`)
browser = launched.browser
page = launched.page
const h1Text = await page.evaluate(() => {
return document.querySelector('h1').textContent
})
function startServers(callback) {
readyCallback = callback;
http_server.createServer().listen(HTTP_PORT);
var msg = 'Tests: http://127.0.0.1:' + HTTP_PORT + '/test/index.html';
if (process.env.COUCH_HOST) {
msg += '?couchHost=' + process.env.COUCH_HOST;
}
console.log(msg);
serverStarted = true;
checkReady();
}
}
};
let cwd = process.cwd();
let port = 8527;
let host = '0.0.0.0';
let options = {
root: cwd,
cache: false,
showDir: true,
autoIndex: true
};
let srcDir = path.resolve(__dirname, '../src');
let server = httpServer.createServer(options);
let pretest = spawn('npm', ['run', 'pretest']);
pretest.stderr.on('data', data => {
console.log(`${data}`);
});
pretest.on('close', code => {
server.listen(port, host, function () {
let canonicalHost = host === '0.0.0.0' ? '127.0.0.1' : host;
let protocol = 'http://';
logger.info(['Starting up http-server, serving '.yellow,
server.root.cyan,
'\nAvailable on:'.yellow
].join(''));
var serverPromise = new Promise(function (resolve, reject) {
hs.createServer({root: './www'}).listen(9000, function (err) {
if (err) {
return reject(err);
}
resolve();
});
});
let options = {
root: ".",
cache: "-1",
showDir: true,
autoIndex: true
}
let self = this;
if (this.params.transformPath){
options.root = this.params.transformPath;
options.before = [ fsUtils.getTransformerWraper(options.root, self.transformTarget ) ];
}else{
options.before = [ fsUtils.getTransformerWraper(process.cwd(), self.transformTarget ) ]
}
self.bindProcessEvent();
let server = httpServer.createServer();
let port = this.params.port;
//npmlog.info(`http port: ${port}`)
server.listen(port, "0.0.0.0", function () {
npmlog.info((new Date()) + `http is listening on port ${port}`)
if (self.transformServerPath){
let IP = nwUtils.getPublicIP()
if (self.params.host != DEFAULT_HOST){
IP = self.params.host;
}
npmlog.info(`target file in local path ${self.parmas.transformPath} will be transformer to JS bundle\nplease access http://${IP}:${port}/`);
return;
}
if (self.params.qr || self.params.smallqr){
gulp.task('example', function(cb) {
var hs = require("http-server");
var open = require('open');
var server = hs.createServer({"root": "./"});
server.listen(8080);
open("http://127.0.0.1:8080");
cb();
});