Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var http = require('urllib').create();
var shell = require('shelljs');
var path = require('path');
var fs = require('fs');
var logger = require('../utils/logger');
var resource = {
url: 'http://cn.bing.com/HPImageArchive.aspx',
params: {
format: 'js', // return json
idx: 0, // 0 - today, 1 - yesterday, 2 - the day before yesterday ...
n: 1 // how many images in the result
}
};
exports.first = function (cb) {
// 1. get image url
'use strict';
var http = require('urllib').create();
var shell = require('shelljs');
var path = require('path');
var fs = require('fs');
var logger = require('../utils/logger.js');
exports.first = function (cb) {
// implement your logic here, cb need a image path based on filesystem.
// Then specify --source=your in command line, and have fun.
//
// Also I would appreciate it if you could share your source at:
// https://github.com/micooz/wallpaper/pulls
//
// cb(file);
};
'use strict';
var http = require('urllib').create();
var shell = require('shelljs');
var path = require('path');
var fs = require('fs');
var logger = require('../utils/logger.js');
var _uri = '';
function _first(cb) {
logger.info('downloading from: ' + _uri);
http.request(_uri, {}, function (err, data) {
var file = path.join(shell.tempdir(), 'tmp.jpg');
fs.writeFile(file, data, function (err) {
if (err) {
logger.fatal('cannot save image to: ' + file);
process.exit(-1);
constructor(options) {
options = options || {};
this.name = options.name || 'egg-init';
this.configName = options.configName || 'egg-init-config';
this.pkgInfo = options.pkgInfo || require('../package.json');
this.needUpdate = options.needUpdate !== false;
this.httpClient = urllib.create();
this.inquirer = inquirer;
this.fileMapping = {
gitignore: '.gitignore',
_gitignore: '.gitignore',
'_.gitignore': '.gitignore',
'_package.json': 'package.json',
'_.eslintignore': '.eslintignore',
'_.npmignore': '.npmignore',
};
}
makeRequest (params, options = {}) {
const httpclient = urllib.create()
return httpclient.request(GETWAY, Object.assign({}, {
data: params,
dataType: 'json',
dataAsQueryString: true
}, options))
.then(resp => this.makeResponse(resp.data))
}
});
} else {
throw new TypeError('httpProxy format error: ' + config.httpProxy);
}
} else {
httpAgent = new HttpAgent({
timeout: 0,
keepAliveTimeout: 15000
});
httpsAgent = new HttpsAgent({
timeout: 0,
keepAliveTimeout: 15000
});
}
var client = urllib.create({
agent: httpAgent,
httpsAgent: httpsAgent
});
module.exports = client;
module.exports.USER_AGENT = urllib.USER_AGENT;