GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — vscode-react-native/tools/gulp-extras.js at master · microsoft/vscode-react-native Expand file tree/ Copy pathgulp-extras.jsMore file actions 133 lines (115 loc) · 4 KB / Copy pathgulp-extras.jsFile metadata and controls133 lines (115 loc) · 4 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for details. "use strict"; const child_process = require("child_process"); const fs = require("fs"); const log = require("fancy-log"); const colors = require("ansi-colors"); const path = require("path"); const PluginError = require("plugin-error"); const through = require("through2"); /** * Pretty logger using 'log' * @param {string} pluginName Name of the pluginName * @param {Object} file A gulp file to report on * @param {string} message The error message to display */ function logError(pluginName, file, message) { const sourcePath = path.relative(__dirname, file.path).replace(/..\//g, "''"); log(`[${colors.cyan(pluginName)}] ${colors.red("error")} ${sourcePath}: ${message}`); } /** * Plugin to verify the Microsoft copyright notice is present */ function checkCopyright() { const pluginName = "check-copyright"; let hadErrors = false; const copyrightNotice = "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for details."; return through.obj( function (file, encoding, callback) { if (file.isBuffer()) { let fileContents = file.contents.toString(encoding); fileContents = fileContents.replace("\r\n", "\n"); fileContents = fileContents.replace('"use strict";\n', ""); fileContents = fileContents.replace( 'Object.defineProperty(exports, "__esModule", { value: true });\n', "", ); if (fileContents.indexOf(copyrightNotice) !== 0) { logError(pluginName, file, "missing copyright notice"); hadErrors = true; } } callback(null, file); }, function (callback) { if (hadErrors) { return this.emit("error", new PluginError(pluginName, "Failed copyright check")); } callback(); }, ); } /** * Helper function to check if a file exists case sensitive * @param {string} filePath The path to check * @returns {boolean} If the path exists case sensitive */ function existsCaseSensitive(filePath) { if (fs.existsSync(filePath)) { const fileName = path.basename(filePath); return fs.readdirSync(path.dirname(filePath)).indexOf(fileName) !== -1; } return false; } function executeCommand(command, args, callback, opts) { const proc = child_process.spawn( command + (process.platform === "win32" ? ".cmd" : ""), args, Object.assign({}, opts, { shell: true }), ); let errorSignaled = false; proc.stdout.on("data", data => { log(`${data}`); }); proc.stderr.on("data", data => { log.error(`${data}`); }); proc.on("error", error => { if (!errorSignaled) { callback(`An error occurred. ${error}`); errorSignaled = true; } }); proc.on("exit", code => { if (code === 0) { callback(); } else if (!errorSignaled) { callback(`Error code: ${code}`); errorSignaled = true; } }); } async function withTimeout(promise, ms, { onTimeout, fallbackValue } = {}) { let timer; const guarded = promise .then(value => ({ kind: "ok", value })) .catch(error => ({ kind: "error", error })); const timed = new Promise(resolve => { timer = setTimeout(() => { if (onTimeout) onTimeout(); resolve({ kind: "timeout", value: fallbackValue }); }, ms); }); const result = await Promise.race([guarded, timed]); clearTimeout(timer); if (result.kind === "error") throw result.error; if (result.kind === "timeout") return result.value; return result.value; } module.exports = { checkCopyright, executeCommand, withTimeout, }; |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |