it('doesn\'t add .js if it has another extension', function() { addon.pkg['ember-addon']['main'] = 'index.coffee'; var resolvedFile = path.basename(Addon.resolvePath(addon)); assert.equal(resolvedFile, 'index.coffee'); });
image.resizeCenter(300, 300).save(filename, function(err, filename) { model.url = '<div><img src="/{0}?ts={1}" width="300" height="300" alt="Uploaded image" /></div><br />'.format(path.basename(filename), new Date().getTime()); self.view('homepage', model); });
files.forEach(function(file) { var basename = path.basename(file, ".js"), extname = path.extname(file); if (extname === ".js") all[basename] = require(path.join(dirname, file)); });
async.eachLimit(this.files, concurrencyCount, function (file, next) { var src = file.src[0]; if (typeof src !== 'string') { src = file.orig.src[0]; } if (!grunt.file.exists(src)) { grunt.log.warn('Source file "' + src + '" not found.'); return next(); } if (path.basename(src)[0] === '_') { return next(); } var args = [ src, file.dest ].concat(passedArgs); if (options.update) { // When the source file hasn't yet been compiled SASS will write an empty file. // If this is the first time the file has been written we treat it as if `update` was not passed if (!grunt.file.exists(file.dest)) { // Find where the --update flag is and remove it args.splice(args.indexOf('--update'), 1); } else { // The first two elements in args are the source and destination files, // which are used to build a path that SASS recognizes, i.e. "source:destination" args.push(args.shift() + ':' + args.shift()); } } var bin = 'sass'; if (options.bundleExec) { bin = 'bundle'; args.unshift('exec', 'sass'); } // If we're compiling scss or css files if (path.extname(src) === '.css') { args.push('--scss'); } // Make sure grunt creates the destination folders if they don't exist if (!grunt.file.exists(file.dest)) { grunt.file.write(file.dest, ''); } grunt.verbose.writeln('Command: ' + bin + ' ' + args.join(' ')); var cp = spawn(bin, args, {stdio: 'inherit'}); cp.on('error', grunt.warn); cp.on('close', function (code) { if (code > 0) { return grunt.warn('Exited with error code ' + code); } // Callback to insert banner if (options.banner) { bannerCallback(file.dest, options.banner); } grunt.verbose.writeln('File ' + chalk.cyan(file.dest) + ' created.'); next(); }); }, cb);
function UninstallFile(file) { return fs.removeAsync(path.join(file.dest, path.basename(file.src))); }
var isModule = function(currentPath) { return isValidDirectory(currentPath) && fs.existsSync(path.join(currentPath, path.basename(currentPath) + '.js')); };
fs.stat(fullPath, function(e, f) { if (e) { console.log('Error: ', e); return; } if (f.isDirectory()) { walk(fullPath); } else { // mp4 to jpg if (path.extname(fullPath) === '.mov') { var cmd04 = 'ffmpeg -i ' + '\"' + fullPath + '\"' + ' -ss 00:01:00.00 -r 1 -an -vframes 1 -s 418x235 -f mjpeg ' + '\"' + path.join(path.dirname(fullPath), path.basename(fullPath, '.mov')) + '-0.png' + '\"' ; execSync(cmd04); } } });
function validateCreateArgs(args) { if (args.host && !args.host.match(ip_regex) && !args.host.match(dns_regex)) { throw Cli.error.invalid('--host must specify a valid IP address or DNS domain name'); } if (args.capture && args.watch) { throw Cli.error.invalid('--watch is incompatible with --capture'); } if (args.capture && args.bundle) { throw Cli.error.invalid('--bundle is incompatible with --capture'); } if (!args.file_or_url && args.bundle) { throw Cli.error.invalid('--bundle can not be used when reading from `stdin`'); } if (!args.file_or_url && args.watch) { throw Cli.error.invalid('--watch can not be used when reading from `stdin`'); } var fileOrUrl = args.file_or_url; if (fileOrUrl && fileOrUrl.match(/^https?:\/\//i)) { if (args.watch) { throw Cli.error.invalid('The --watch option can only be used ' + 'when a file name is specified'); } if (args.bundle && !args.capture) { throw Cli.error.invalid('The --bundle option can only be used ' + 'when a file name is specified'); } args.source = 'url'; args.spec = fileOrUrl; } else if (fileOrUrl) { if (args.capture) { throw Cli.error.invalid('The --capture option can only be used ' + 'when a url is specified'); } args.source = 'file'; args.spec = Path.resolve(process.cwd(), fileOrUrl); } else { args.source = 'stdin'; args.spec = process.cwd(); } if (!args.name) { // The md5 approach is here for redundancy, but in practice, it seems // that Path.basename() will resolve to something intelligent all the // time. args.name = Path.basename(args.spec, Path.extname(args.spec)) || require('crypto') .createHash('md5') .update(args.spec) .digest('hex'); } parseKeyValList(args, 'secrets'); parseKeyValList(args, 'params'); return args; function parseKeyValList(args, field) { args[field] = _.reduce(args[field], function (acc, entry) { var parts = entry.split('='); return _.set(acc, parts.shift(), parts.join('=')); }, {}); } }
var getImportBaseName = function (href) { return lodash_1.upperFirst(lodash_1.camelCase(path.basename(href).split(".").shift())); };
beforeEach: function() { this.salsa20 = new Salsa20(this.key, [255,255,255,255,255,255,255,255]) }, 'Check first 512 bytes': function() { test.assert.same( this.salsa20.getHexString(512), 'b342fa48e76835d16a17b20cade51c3337f93c9819dd9866475196010d258f94' + '95eadc0d3dde542cceba358bb99a744e2fe699f6e6f98e30abdd007c24c2aa72' + '3b6719f0bcabaeeb7d420c3d4f48c40864401ca929081bf7e888d3ef7f99e247' + '0ac7a80605345aa824499672393ae8896a2ef55e3e0275c6c21d49bb18482a29' + '773c34e31e597eb01ff9ca0db33a288c00c2615758fe6f1832f3afdefc7c195a' + '749581d04ecbf86903af3e5767fed1f43fd6232c5798f75136ce366cf7737fa1' + '0a6c066fd77be5b1bf62e5b13c357010cce314f6e5aa0a36cef10eb57e301745' + '1a98c0e50cf0cadfd2d26134b4c35a08013019a0157eae3798f72b567e2edfc6' + '3415101bd2e7cf60d303a8bd926cd0a7184a8a4053838100249e2c4fd79ba120' + 'bd24202a1f7db642871170a4a2d03997f76339d25e7ab5c8a18f9e12a372a9f9' + '5ef561b275dca094d78174fab8aefb5ac3cf82e873e2a8373b144f9bf9448b06' + '16fdaa0a3b367fb677546412c0a038d8c5677feb334dd52ad14f555c596de436' + '3e445dd70da65d732de4432b5e2cca05e654cf640f12ec6bad59c26cc9e906ea' + '48e2161a4f186d5da764b12cd9480e4686db9391f2d29cd1696b5e584bb04b6f' + 'feb815e1709f39c1e24aa344014b3616b1c34bb034644233857dd33a6ee428d1' + '90b0d1438f8e6730221226c452c6ff1f0122ac47ac3a477f2f8bf4659d4c5ad9' ) } } } } module.exports[path.basename(__filename)] = test
function getName(file) { return '/' + path.basename(file).replace(path.extname(file), ''); }
// Direct URL of source PDF file. const SourceFileUrl = "https://s3-us-west-2.amazonaws.com/bytescout-com/files/demo-files/cloud-api/pdf-to-text/sample.pdf"; // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. const Pages = ""; // PDF document password. Leave empty for unprotected documents. const Password = ""; // Destination TXT file name const DestinationFile = "./result.txt"; // Sample profile that sets advanced conversion options // Advanced options are properties of TextExtractor class from ByteScout Text Extractor SDK used in the back-end: // https://cdn.bytescout.com/help/BytescoutPDFExtractorSDK/html/8a2bae5a-346f-8338-b5aa-6f3522dca0d4.htm const Profiles = '{ "profiles": [ { "profile1": { "TrimSpaces": "False", "PreserveFormattingOnTextExtraction": "True", "Unwrap": "True" } } ] }'; // Prepare request to `PDF To Text` API endpoint var queryPath = `/v1/pdf/convert/to/text?name=${path.basename(DestinationFile)}&password=${Password}&pages=${Pages}&url=${SourceFileUrl}&profiles=${Profiles}&async=True`; var reqOptions = { host: "api.pdf.co", path: encodeURI(queryPath), headers: { "x-api-key": API_KEY } }; // Send request https.get(reqOptions, (response) => { response.on("data", (d) => { // Parse JSON response var data = JSON.parse(d); if (data.error == false) { console.log(`Job #${data.jobId} has been created!`);
glob.sync(globPath).forEach(function(entry) { basename = path.basename(entry, path.extname(entry)); tmp = entry.split('/').splice(-3); pathname = tmp.splice(0, 1) + '/' + basename; // æ£ç¡®è¾“出jså’Œhtml的路径 entries[pathname] = entry; });
rollup({entry, plugins}).then((bundle) => { try { const rollupResult = bundle.generate({ format: 'es', dest: output, sourceMap: true, }); const externsDir = path.resolve(__dirname, '../lib/externs'); const externs = glob.sync(path.join(externsDir, '*.js')) .reduce((acc, cur) => acc + fs.readFileSync(cur, 'utf-8'), ''); const closureFlags = { jsCode: [{ src: rollupResult.code, path: path.basename(output), }], compilationLevel: 'ADVANCED', useTypesForOptimization: true, outputWrapper: '(function(){%output%})();\n' + `//# sourceMappingURL=${path.basename(output)}.map`, assumeFunctionWrapper: true, rewritePolyfills: false, warningLevel: 'VERBOSE', createSourceMap: true, externs: [{src: externs}], }; const closureResult = compile(closureFlags); if (closureResult.errors.length || closureResult.warnings.length) { const rollupMap = new SourceMapConsumer(rollupResult.map); // Remap errors from the closure compiler output to the original // files before rollup bundled them. const remap = (type) => (item) => { let {line, column, source} = rollupMap.originalPositionFor({ line: item.lineNo, column: item.charNo, }); source = path.relative('.', path.resolve(__dirname, '..', source)); return {type, line, column, source, desc: item.description}; }; reject({ errors: [ ...closureResult.errors.map(remap('error')), ...closureResult.warnings.map(remap('warning')), ], }); } else { // Currently, closure compiler doesn't support applying its generated // source map to an existing source map, so we do it manually. const fromMap = JSON.parse(closureResult.sourceMap); const toMap = rollupResult.map; const generator = SourceMapGenerator.fromSourceMap( new SourceMapConsumer(fromMap)); generator.applySourceMap( new SourceMapConsumer(toMap), path.basename(output)); const sourceMap = generator.toString(); resolve({ code: closureResult.compiledCode, map: sourceMap, }); } } catch(err) { reject(err); } }).catch(reject);
process.on('close', function(code) { if (code != 0) return callback(new Error(stderr)); var newHash = stdout.trimRight(); callback(null, [newHash, path.basename(changedDir)]); });
module.exports = function (txt, filename, sourceFileName) { var Title = txt.match(/^[^"]*"([^"]+)"/), rdoc = /\/\*\\[\s\S]*?\\\*\//g, rdoc2 = /^\/\*\\\n\s*\*\s+(.*)\n([\s\S]*)\\\*\/$/, rows = /^\s*(\S)(?:(?!\n)\s(.*))?$/, // rcode = /`([^`]+)`/g, rkeywords = /\b(abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|long|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|var|void|volatile|while|with|undefined)\b/g, rstrings = /("[^"]*?(?:\\"[^"]*?)*"|'[^']*?(?:\\'[^']*?)*')/g, roperators = /( \= | \- | \+ | % | \* | \&\& | \&\& | \& | \& | \|\| | \| | \/ | == | === )/g, rdigits = /(\b(0[xX][\da-fA-F]+)|((\.\d+|\b\d+(\.\d+)?)(?:e[-+]?\d+)?))\b/g, rcomments = /(\/\/.*?(?:\n|$)|\/\*(?:.|\s)*?\*\/)$/g, // rhref = /(https?:\/\/[^\s"]+[\d\w_\-\/])/g, rlink = /(^|\s)@([\w\.\_\$]*[\w\_\$])/g, ramp = /&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, rantiwrap = /^<([^>]+)>(.*)<\/\1>$/, main = txt.match(rdoc), root = {}, mode, html, jsonLevel = 0, src = "", list = [[]], curlist = list[0], srcfilename = sourceFileName || (path.basename(filename, path.extname(filename)) + "-src.html"), clas = "", TOC = [], utoc = {}, chunks = {}, out = {}; if (!main) { return {}; } console.log(markdown.toHTML("eve")) function esc(text) { return markdown.toHTML(String(text)).replace(rantiwrap, "$2").replace(ramp, '<em class="amp">&</em>').replace(rlink, '$1<a href="#$2" class="dr-link">$2</a>'); } function syntax(text) { if(text) return text.replace(/</g, "<").replace(ramp, "&").replace(rkeywords, "<b>$1</b>").replace(rstrings, "<i>$1</i>").replace(roperators, '<span class="s">$1</span>').replace(rdigits, '<span class="d">$1</span>').replace(rcomments, '<span class="c">$1</span>') + "\n"; else return '\n'; } function syntaxSrc(text) { var isend = text.match(/\*\//); if (text.match(/\/\*/)) { syntaxSrc.inc = true; } var out = text.replace(/</g, "<").replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, "&").replace(rkeywords, "<b>$1</b>").replace(rstrings, "<i>$1</i>").replace(roperators, '<span class="s">$1</span>').replace(rdigits, '<span class="d">$1</span>').replace(/(\/\*(?:.(?!\*\/))+(?:\*\/)?)/g, '<span class="c">$1</span>').replace(rcomments, '<span class="c">$1</span>') + "\n"; if (syntaxSrc.inc) { out = out.replace(/(^.*\*\/)/, '<span class="c">$1</span>'); if (!isend) { out = '<span class="c">' + out + '</span>'; } } if (isend) { syntaxSrc.inc = false; } return out; } eve.on("doc.*.list", function (mod, text) { this != "-" && (html += "</dl>\n"); }); eve.on("doc.*.json", function (mod, text) { this != "o" && (html += "</ol>\n"); }); eve.on("doc.*.text", function (mod, text) { this != "*" && (html += "</p>\n"); }); eve.on("doc.*.head", function (mod, text) { this != "*" && (html += "</p>\n"); }); eve.on("doc.*.code", function (mod, text) { this != "|" && (html += "</code></pre>\n"); }); eve.on("doc.s*.*", function (mod, text) { mode != "text" && (html += "<p>"); if (text) { html += esc(text) + "\n"; } else { html += "</p>\n<p>"; } mode = "text"; }); eve.on("doc.s|.*", function (mod, text) { mode != "code" && (html += '<pre class="javascript code"><code>'); html += syntax(text); mode = "code"; }); eve.on("doc.s#.*", function (mod, text) { html += text + "\n"; mode = "html"; }); eve.on("doc.s>.*", function (mod, text) { mode != "head" && (html += '<p class="header">'); html += esc(text) + "\n"; mode = "head"; }); eve.on("doc.s[.*", function (mod, text) { var type; text = esc(text).replace(/\(([^\)]+)\)/, function (all, t) { type = t; return ""; }); itemData.type = esc(text).replace(/\s*\]\s*$/, "").split(/\s*,\s*/); clas = itemData.clas = "dr-" + itemData.type.join(" dr-"); html += '<div class="' + clas + '">'; type && (html += '<em class="dr-type dr-type-' + type + '">' + type + '</em>'); mode = ""; }); eve.on("doc.end.*", function (mod, text) { clas && (html += "</div>"); }); eve.on("doc.s=.*", function (mod, text) { var split = text.split(/(\s*[\(\)]\s*)/); split.shift(); split.shift(); if( split) var types = split.shift().split(/\s*\|\s*/); else var types = ['undefined']; split.shift(); html += '<p class="dr-returns"><strong class="dr-title">Returns:</strong> '; for (var i = 0, ii = types.length; i < ii; i++) { types[i] = '<em class="dr-type-' + types[i] + '">' + types[i] + '</em>'; } html += types.join(" ") + ' <span class="dr-description">' + esc(split.join("")) + "</span></p>\n"; mode = ""; }); eve.on("doc.s-.*", function (mod, text) { itemData.params = itemData.params || []; if (mode != "list") { html += '<dl class="dr-parameters">'; itemData.params.push([]); } var optional, data = itemData.params[itemData.params.length - 1]; text = text.replace(/#optional\s*/g, function () { optional = true; return ""; }); var split = text.split(/(\s*[\(\)]\s*)/); data.push((optional ? "[" : "") + split[0] + (optional ? "]" : "")); html += '<dt class="dr-param' + (optional ? " optional" : "") + '">' + split.shift() + '</dt>\n'; split.shift(); if (optional) { html += '<dd class="dr-optional">optional</dd>\n'; } var types = split.shift().split(/\s*\|\s*/); split.shift(); html += '<dd class="dr-type">'; for (var i = 0, ii = types.length; i < ii; i++) { types[i] = '<em class="dr-type-' + types[i] + '">' + types[i] + '</em>'; } html += types.join(" ") + '</dd>\n<dd class="dr-description">' + (esc(split.join("")) || " ") + '</dd>\n'; mode = "list"; }); eve.on("doc.so.*", function (mod, text) { if (mode != "json") { html += '<ol class="dr-json">'; } var desc = text.match(/^\s*([^\(\s]+)\s*\(([^\)]+)\)\s*(.*?)\s*$/), start = text.match(/\s*\{\s*$/), end = text.match(/\s*\}\s*,?\s*$/); !end && (html += "<li>"); if (desc) { html += '<span class="dr-json-key">' + desc[1] + '</span>'; var types = desc[2].split(/\s*\|\s*/); html += '<span class="dr-type">'; for (var i = 0, ii = types.length; i < ii; i++) { types[i] = '<em class="dr-type-' + types[i] + '">' + types[i] + '</em>'; } html += types.join(" ") + '</span><span class="dr-json-description">' + (esc(desc[3]) || " ") + '</span>\n'; } else { !end && (html += text); } if (start) { html += '<ol class="dr-json">'; } if (end) { html += '</ol></li><li>' + text + '</li>'; } mode = "json"; }); out.sections = main.length; main = txt.split("\n"); out.loc = main.length; var beginrg = /^\s*\/\*\\\s*$/, endrg = /^\s*\\\*\/\s*$/, line = 0, pointer, firstline = false, inside = false; for (var i = 0, ii = main.length; i < ii; i++) { var doc = main[i]; line++; src += '<code id="L' + line + '"><span class="ln">' + line + '</span>' + syntaxSrc(doc) + '</code>'; if (doc.match(beginrg)) { inside = firstline = true; pointer = root; itemData = {}; html = ""; mode = ""; continue; } if (doc.match(endrg)) { inside = false; eve("doc.end." + mode, null, mode, ""); itemData.line = line + 1; (function (value, Clas, data, pointer) { eve.on("doc.item", function () { if (this == pointer) { html += value; itemData = data; } }); })(html, clas, itemData, pointer); clas = ""; continue; } if (inside) { var title, data = doc.match(rows); if (data) { var symbol = data[1], text = data[2]; if (symbol == "*" && firstline) { firstline = false; title = text.split("."); for (var j = 0, jj = title.length; j < jj; j++) { pointer = pointer[title[j]] = pointer[title[j]] || {}; } } else { eve("doc.s" + symbol + "." + mode, symbol, mode, text); } } } } html = ""; var lvl = [], toc = "", itemData, res = ""; var runner = function (pointer, hx) { var level = [], name, chunk; for (var node in pointer) { level.push(node); } level.sort(); for (var j = 0, jj = level.length; j < jj; j++) { lvl.push(level[j]); name = lvl.join("."); html = ""; chunk = ""; itemData = {}; eve("doc.item", pointer[level[j]]); chunk += '<div class="' + name.replace(/\./g, "-") + '-section"><h' + hx + ' id="' + name + '" class="' + itemData.clas + '"><i class="dr-trixie"> </i>' + name; if (itemData.type && (itemData.type.indexOf("method") + 1 || itemData.type.indexOf("class") + 1 )) { if (itemData.params) { if (itemData.params.length <= 3) { chunk += "(" + itemData.params[0].join(", ") + ")"; } else if (!itemData.params.length) { chunk += "()"; } else { chunk += "(\u2026)"; } } else { chunk += "()"; } } chunk += '<a href="#' + name + '" title="Link to this section" class="dr-hash">⚓</a>'; itemData.line && (chunk += '<a class="dr-sourceline" title="Go to line ' + itemData.line + ' in the source" href="' + srcfilename + '#L' + itemData.line + '">➭</a>'); chunk += '</h' + hx + '>\n'; chunk += '<div class="extra" id="' + name + '-extra"></div></div>'; chunk += html; chunks[name] = chunks[name] || ""; chunks[name] += chunk; res += chunk; var indent = 0; name.replace(/\./g, function () { indent++; }); toc += '<li class="dr-lvl' + indent + '"><a href="#' + name + '" class="' + itemData.clas + '"><span>' + name; if (itemData.type && itemData.type.indexOf("method") + 1) { toc += "()"; } toc += '</span></a></li>'; if (!utoc[name]) { TOC.push({ indent: indent, name: name, clas: itemData.clas, brackets: itemData.type && itemData.type.indexOf("method") + 1 ? "()" : "" }); utoc[name] = 1; } runner(pointer[level[j]], hx + 1); lvl.pop(); } }; runner(root, 2); out.chunks = chunks; out.toc = TOC; out.title = Title ? Title[1] : ""; out.source = '<!DOCTYPE html>\n<!-- Generated with Dr.js -->\n<html lang="en"><head><meta charset="utf-8"><title>' + path.basename(filename) + '</title><link rel="stylesheet" href="dr.css"></head><body id="src-dr-js">' + src + '</body></html>'; eve.unbind("doc.*"); return out; };
var isValidDirectory = function(currentPath) { var blacklistedDirectories = ['lib', 'bower_components']; return fs.statSync(currentPath).isDirectory() && blacklistedDirectories.indexOf(path.basename(currentPath)) === -1; };
module.exports = function (grunt) { 'use strict'; //var path = require('path'); var path = require('path'); var gtx = require('../../../lib/gtx.js').wrap(grunt); //gtx.debug = true; gtx.loadTasks('../../../node_modules/grunt-contrib-clean/tasks'); gtx.loadTasks('../../test_tasks'); gtx.config({ clean: { tests: ['tmp/**/*'] }, echo: { before: { options: { echo: 'before: ' + path.basename(__filename) } }, after: { options: { echo: 'after: ' + path.basename(__filename) } }, echo: { options: { echo: 'echo' } } } }); gtx.define('echoList', function (macro, id) { macro.log('Test!'); var defaultWait = 200; var wait = macro.getParam('wait', defaultWait); if (wait > defaultWait) { macro.tag('slow'); } else if (wait < defaultWait) { macro.tag('fast'); } var str = id + ' says: '; macro.add('echo', { options: { echo: str + 'one', wait: wait * 2 } }); macro.add('echo', { options: { echo: str + 'two two', wait: wait } }); macro.log('Done!'); }, { concurrent: 3 }); gtx.create('alpha,bravo,charlie,delta,echo,foxtrot,golf,hotel,india', 'echoList', {wait: 200}); gtx.create('tango,victory', 'echoList', {wait: 500}); gtx.create('oscar,mike', 'echoList', {wait: 100}); gtx.create('xray', 'echoList', {wait: 1000}); gtx.alias('default', ['test']); gtx.alias('test', ['gtx-type:echoList:xm']); gtx.alias('dev', ['gtx-type:echoList']); gtx.finalise(); };
CLI.start = function(script, opts, cb) { var appConf = { script : script, name : p.basename(script, '.js') }; if (typeof opts == "function") { cb = opts; opts = {}; } if (opts.nodeArgs) { //maintain backwards compat for space delimited string args if (Array.isArray(opts.nodeArgs)){ appConf['node_args'] = opts.nodeArgs; } else { appConf['node_args'] = opts.nodeArgs.split(' '); } } else { appConf.node_args = []; } if (opts.scriptArgs) appConf['args'] = JSON.stringify(opts.scriptArgs); if (opts.name) appConf['name'] = opts.name; if (opts.maxMemoryRestart) appConf.max_memory_restart = opts.maxMemoryRestart; if (opts.instances) appConf['instances'] = opts.instances; if (opts.error) appConf['error_file'] = opts.error; if (opts.output) appConf['out_file'] = opts.output; if (opts.pid) appConf['pid_file'] = opts.pid; if (opts.cron) appConf['cron_restart'] = opts.cron; if (opts.cwd) appConf['cwd'] = opts.cwd; if (opts.mergeLogs) appConf['merge_logs'] = true; if (opts.watch) appConf['watch'] = true; if (opts.env) appConf['env'] = opts.env; if (opts.runAsUser) appConf['run_as_user'] = opts.runAsUser; if (opts.runAsGroup) appConf['run_as_group'] = opts.runAsGroup; if (opts.logDateFormat) appConf['log_date_format'] = opts.logDateFormat; if (typeof(opts.minUptime) !== 'undefined') appConf['min_uptime'] = opts.minUptime; if (typeof(opts.maxRestarts) !== 'undefined') appConf['max_restarts'] = opts.maxRestarts; if (appConf['instances']) appConf['exec_mode'] = 'cluster_mode'; else appConf['exec_mode'] = 'fork_mode'; if (opts.executeCommand) { appConf['exec_mode'] = 'fork_mode'; if (opts.interpreter) appConf['exec_interpreter'] = opts.interpreter; else if (extItps[path.extname(script)]) appConf['exec_interpreter'] = extItps[path.extname(script)]; else appConf['exec_interpreter'] = 'none'; } // else { // appConf['exec_mode'] = 'cluster_mode'; // appConf['exec_interpreter'] = 'node'; // } if (opts.execMode) { appConf['exec_mode'] = opts.execMode; } if (appConf['exec_mode'] == 'cluster_mode' && process.version.match(/0.10/) && !opts.force && !process.env.TRAVIS) { //appConf['exec_mode'] = 'fork_mode'; //appConf['instances'] = 1; printOut(chalk.yellow('[PM2] You shouldn\'t use the cluster_mode with node 0.10.x. Instead use fork mode with -x')); } // Script arguments if (opts.rawArgs) { var env = opts.rawArgs.indexOf('--') + 1; if (env > 1) appConf['args'] = JSON.stringify(opts.rawArgs.slice(env, opts.rawArgs.length)); } if (opts.write) { var dst_path = path.join(process.env.PWD, path.basename(script, '.js') + '-pm2.json'); printOut(cst.PREFIX_MSG + 'Writing configuration to ', dst_path); fs.writeFileSync(dst_path, JSON.stringify(appConf)); } /* * Re start script name that is already launched */ Satan.executeRemote('findByFullPath', path.resolve(process.cwd(), script), function(err, exec) { if (exec && (exec[0].pm2_env.status == cst.STOPPED_STATUS || exec[0].pm2_env.status == cst.STOPPING_STATUS)) { var app_name = exec[0].pm2_env.name; Satan.executeRemote('restartProcessName', app_name, function(err, list) { printOut(cst.PREFIX_MSG + 'Process successfully started'); if (cb) return cb(null, list); else return speedList(); }); return false; } else if (exec && !opts.force) { printError(cst.PREFIX_MSG_ERR + 'Script already launched, add -f option to force re execution'); if (cb) return cb({success:false}); else return exitCli(cst.ERROR_EXIT); } try { var resolved_paths = resolvePaths(appConf); } catch(e) { if (cb) return cb(e); else return exitCli(cst.ERROR_EXIT); } Satan.executeRemote('prepare', resolved_paths, function(err, data) { if (err) { printError(cst.PREFIX_MSG_ERR + 'Error while launching application', err.stack || err); if (cb) return cb({msg : err}); else return speedList(); } printOut(cst.PREFIX_MSG + 'Process %s launched', script); if (cb) return cb(null, data); else return speedList(); }); return false; }); };
matchingProjects.forEach(function (project) { solText = solText.replace(getJsProjRegExForProject(path.basename(project.location)), function (match) { return match + preInsertText; }); });
function result(buff) { return { contents: JSON.parse(buff.contents.toString()), file: path.basename(buff.path) }; }
value: function _writetestOne(params, cb) { var self = this; if (!params.func_name) { throw new Error('No func_name in ' + JSON.stringify(params)); } if (!params.headKeys) { throw new Error('No headKeys in ' + params.func_name); } if (!params.headKeys.example) { throw new Error('No example in ' + params.func_name); } var basename = path.basename(params.filepath); var subdir = path.dirname(params.filepath); var testpath = this.__test + '/languages/' + subdir + '/test-' + basename; var testdir = path.dirname(testpath); var relativeSrcForTestDir = path.relative(testdir, self.__src); var relativeTestFileForRoot = path.relative(self.__root, testpath); // console.log(relativeSrcForTestDir) // process.exit(1) var testProps = ''; if (params.headKeys.test) { testProps = params.headKeys.test[0][0]; } var describeSkip = ''; if (self.allowSkip && testProps.indexOf('skip-all') !== -1) { describeSkip = '.skip'; } var codez = []; codez.push('// warning: This file is auto generated by `npm run build:tests`'); codez.push('// Do not edit by hand!'); // Add globals for (var global in self.globals) { codez.push('var ' + global + ' = ' + self.globals[global]); } // Set timezone for testing dates // Not ideal: http://stackoverflow.com/questions/8083410/how-to-set-default-timezone-in-node-js codez.push('process.env.TZ = \'UTC\''); codez.push('var ' + 'expect' + ' = require(\'chai\').expect'); // Add language-wide dependencies // @todo: It would be great if we could remove this if (params.language === 'php') { codez.push(self._addRequire('ini_set', relativeSrcForTestDir + '/' + 'php/info/ini_set')); codez.push(self._addRequire('ini_get', relativeSrcForTestDir + '/' + 'php/info/ini_get')); if (params.func_name === 'localeconv') { codez.push(self._addRequire('setlocale', relativeSrcForTestDir + '/' + 'php/strings/setlocale')); } if (params.func_name === 'i18n_loc_get_default') { codez.push(self._addRequire('i18n_loc_set_default', relativeSrcForTestDir + '/' + 'php/i18n/i18n_loc_set_default')); } } // Add the main function to test codez.push(self._addRequire(params.func_name, relativeSrcForTestDir + '/' + params.filepath)); codez.push(''); codez.push(['describe', describeSkip, '(\'src/', params.filepath, ' (tested in ', relativeTestFileForRoot, ')\', function () {'].join('')); // Run each example for (var i in params.headKeys.example) { if (!params.headKeys.returns[i] || !params.headKeys.returns[i].length) { throw new Error('There is no return for example ' + i, test, params); } var humanIndex = parseInt(i, 10) + 1; var itSkip = ''; if (self.allowSkip && testProps.indexOf('skip-' + humanIndex) !== -1) { itSkip = '.skip'; } codez.push([' it', itSkip, '(\'should pass example ', humanIndex, '\', function (done) {'].join('')); var body = []; var testExpected = params.headKeys.returns[i].join('\n'); body.push('var expected = ' + testExpected); // Execute line by line (see date.js why) // We need result be the last result of the example code for (var j in params.headKeys.example[i]) { if (parseInt(j, 10) === params.headKeys.example[i].length - 1) { // last action gets saved body.push('var result = ' + params.headKeys.example[i][j].replace('var $result = ', '')); } else { body.push(params.headKeys.example[i][j]); } } body.push('expect(result).to.deep.equal(expected)'); body.push('done()'); codez.push(indentString(body.join('\n'), ' ', 4)); codez.push(' })'); } codez.push('})'); codez.push(''); var code = codez.join('\n'); // Write to disk mkdirp(testdir, function (err) { if (err) { throw new Error(err); } debug('writing: ' + testpath); fs.writeFile(testpath, code, 'utf-8', cb); }); }
function InstallFile(baseDir, file) { var src = path.resolve(path.join(baseDir, 'files', file.src)); return fs.copyAsync(src, path.join(file.dest, path.basename(file.src))); }
function noDotFolders(f){return path.basename(f).indexOf('.') !== 0;}
function File(filepath, id) { this.id = id; this.name = path.basename(filepath); this.path = filepath; }
watcher.on('added', function (filepath) { test.equal('added.js', path.basename(filepath)); fs.unlinkSync(filepath); watcher.close(); next(); });
resourceFile.forEach(function(filename) { var filenamePath = path.join(resDirPath, path.basename(filename)); fsExt.writeFileSync(filenamePath, project.getModuleCode(filename)); });
var manifest; try { manifest = fs.readFileSync(manifestFile,'utf8'); manifest = JSON.parse(manifest); if(typeof manifest !== "object") throw new Error('Manifest not an object!'); if(!manifest.files) throw new Error("Manifest has no files!"); } catch(e){ console.error('Invalid '+path.resolve(manifestFile),e,manifest); process.exit(1); } var newFiles = {}; for(var filename in manifest.files) { if(!manifest.files[filename].filename){ var key = path.basename(filename); key = key.substr(0,key.indexOf('.')); newFiles[key] = manifest.files[filename]; newFiles[key].filename = filename; } else { newFiles[filename] = manifest.files[filename]; } } manifest.files = newFiles; try { fs.writeFileSync( path.resolve(rootDir, manifestFile), JSON.stringify(manifest,null,2) ); } catch(e) {
var app = module.parent.parent.exports , config = app.config , mongoose = app.mongoose , Schema = mongoose.Schema , path = require('path') , modelName = path.basename(__filename, '.js') , ModelSchema, Model , models = module.parent.exports ; ModelSchema = new Schema({ from: [models.User] , to: [models.User] , created: Number , body: String }); mongoose.model(modelName, ModelSchema); Model = mongoose.model(modelName); module.exports = mongoose.model(modelName);
it('doesn\'t add .js if it is .js', function() { addon.pkg['ember-addon']['main'] = 'index.js'; var resolvedFile = path.basename(Addon.resolvePath(addon)); assert.equal(resolvedFile, 'index.js'); });