pax_global_header00006660000000000000000000000064130777571520014530gustar00rootroot0000000000000052 comment=e219fae3a4458a1aa4b84002539265a6a1475267 node-getpass-0.1.7/000077500000000000000000000000001307775715200141265ustar00rootroot00000000000000node-getpass-0.1.7/.gitignore000066400000000000000000000000161307775715200161130ustar00rootroot00000000000000node_modules/ node-getpass-0.1.7/.gitmodules000066400000000000000000000003251307775715200163030ustar00rootroot00000000000000[submodule "deps/javascriptlint"] path = deps/javascriptlint url = git://github.com/davepacheco/javascriptlint.git [submodule "deps/jsstyle"] path = deps/jsstyle url = git://github.com/davepacheco/jsstyle.git node-getpass-0.1.7/.npmignore000066400000000000000000000001001307775715200161140ustar00rootroot00000000000000.gitmodules deps docs Makefile node_modules test tools coverage node-getpass-0.1.7/.travis.yml000066400000000000000000000001611307775715200162350ustar00rootroot00000000000000language: node_js node_js: - "5.10" - "4.4" - "4.1" - "0.12" - "0.10" before_install: - "make check" node-getpass-0.1.7/LICENSE000066400000000000000000000020531307775715200151330ustar00rootroot00000000000000Copyright Joyent, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-getpass-0.1.7/Makefile000066400000000000000000000025771307775715200156010ustar00rootroot00000000000000# # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # Copyright (c) 2016, Joyent, Inc. # # # Tools # NPM_EXEC := $(shell which npm) NPM := npm TAP := ./node_modules/.bin/tape JSON := ./node_modules/.bin/json # # Makefile.defs defines variables used as part of the build process. # include ./tools/mk/Makefile.defs # # Configuration used by Makefile.defs and Makefile.targ to generate # "check" and "docs" targets. # DOC_FILES = index.md JSON_FILES = package.json JS_FILES := $(shell find lib test -name '*.js') JSL_FILES_NODE = $(JS_FILES) JSSTYLE_FILES = $(JS_FILES) JSL_CONF_NODE = tools/jsl.node.conf JSSTYLE_FLAGS = -f tools/jsstyle.conf include ./tools/mk/Makefile.defs include ./tools/mk/Makefile.node_deps.defs # # Repo-specific targets # .PHONY: all all: $(SMF_MANIFESTS) | $(TAP) $(REPO_DEPS) $(NPM) rebuild $(TAP): | $(NPM_EXEC) $(NPM) install $(JSON): | $(NPM_EXEC) $(NPM) install CLEAN_FILES += $(TAP) ./node_modules/tap .PHONY: test test: $(TAP) TAP=1 $(TAP) test/*.test.js .PHONY: coverage coverage: all $(NPM_EXEC) install istanbul && \ ./node_modules/.bin/istanbul cover \ $(TAP) test/*.test.js include ./tools/mk/Makefile.deps include ./tools/mk/Makefile.node_deps.targ include ./tools/mk/Makefile.targ node-getpass-0.1.7/README.md000066400000000000000000000014061307775715200154060ustar00rootroot00000000000000## getpass Get a password from the terminal. Sounds simple? Sounds like the `readline` module should be able to do it? NOPE. ## Install and use it ```bash npm install --save getpass ``` ```javascript const mod_getpass = require('getpass'); ``` ## API ### `mod_getpass.getPass([options, ]callback)` Gets a password from the terminal. If available, this uses `/dev/tty` to avoid interfering with any data being piped in or out of stdio. This function prints a prompt (by default `Password:`) and then accepts input without echoing. Parameters: * `options`, an Object, with properties: * `prompt`, an optional String * `callback`, a `Func(error, password)`, with arguments: * `error`, either `null` (no error) or an `Error` instance * `password`, a String node-getpass-0.1.7/deps/000077500000000000000000000000001307775715200150615ustar00rootroot00000000000000node-getpass-0.1.7/deps/javascriptlint/000077500000000000000000000000001307775715200201165ustar00rootroot00000000000000node-getpass-0.1.7/deps/jsstyle/000077500000000000000000000000001307775715200165565ustar00rootroot00000000000000node-getpass-0.1.7/lib/000077500000000000000000000000001307775715200146745ustar00rootroot00000000000000node-getpass-0.1.7/lib/index.js000066400000000000000000000062741307775715200163520ustar00rootroot00000000000000/* * Copyright 2016, Joyent, Inc. All rights reserved. * Author: Alex Wilson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ module.exports = { getPass: getPass }; const mod_tty = require('tty'); const mod_fs = require('fs'); const mod_assert = require('assert-plus'); var BACKSPACE = String.fromCharCode(127); var CTRLC = '\u0003'; var CTRLD = '\u0004'; function getPass(opts, cb) { if (typeof (opts) === 'function' && cb === undefined) { cb = opts; opts = {}; } mod_assert.object(opts, 'options'); mod_assert.func(cb, 'callback'); mod_assert.optionalString(opts.prompt, 'options.prompt'); if (opts.prompt === undefined) opts.prompt = 'Password'; openTTY(function (err, rfd, wfd, rtty, wtty) { if (err) { cb(err); return; } wtty.write(opts.prompt + ':'); rtty.resume(); rtty.setRawMode(true); rtty.resume(); rtty.setEncoding('utf8'); var pw = ''; rtty.on('data', onData); function onData(data) { var str = data.toString('utf8'); for (var i = 0; i < str.length; ++i) { var ch = str[i]; switch (ch) { case '\r': case '\n': case CTRLD: cleanup(); cb(null, pw); return; case CTRLC: cleanup(); cb(new Error('Aborted')); return; case BACKSPACE: pw = pw.slice(0, pw.length - 1); break; default: pw += ch; break; } } } function cleanup() { wtty.write('\r\n'); rtty.setRawMode(false); rtty.pause(); rtty.removeListener('data', onData); if (wfd !== undefined && wfd !== rfd) { wtty.end(); mod_fs.closeSync(wfd); } if (rfd !== undefined) { rtty.end(); mod_fs.closeSync(rfd); } } }); } function openTTY(cb) { mod_fs.open('/dev/tty', 'r+', function (err, rttyfd) { if ((err && (err.code === 'ENOENT' || err.code === 'EACCES')) || (process.version.match(/^v0[.][0-8][.]/))) { cb(null, undefined, undefined, process.stdin, process.stdout); return; } var rtty = new mod_tty.ReadStream(rttyfd); mod_fs.open('/dev/tty', 'w+', function (err3, wttyfd) { var wtty = new mod_tty.WriteStream(wttyfd); if (err3) { cb(err3); return; } cb(null, rttyfd, wttyfd, rtty, wtty); }); }); } node-getpass-0.1.7/package.json000066400000000000000000000007471307775715200164240ustar00rootroot00000000000000{ "name": "getpass", "version": "0.1.7", "description": "getpass for node.js", "main": "lib/index.js", "dependencies": { "assert-plus": "^1.0.0" }, "devDependencies": { "json": "^9.0.3", "pty.js": "^0.3.0", "tape": "^4.4.0" }, "repository": { "type": "git", "url": "https://github.com/arekinath/node-getpass.git" }, "scripts": { "test": "tape test/*.test.js" }, "author": "Alex Wilson ", "license": "MIT" } node-getpass-0.1.7/test/000077500000000000000000000000001307775715200151055ustar00rootroot00000000000000node-getpass-0.1.7/test/basic.test.js000066400000000000000000000040561307775715200175070ustar00rootroot00000000000000/* * Copyright 2016, Joyent, Inc. All rights reserved. * Author: Alex Wilson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ const mod_tape = require('tape'); const mod_pty = require('pty.js'); mod_tape.test('get a password', function (t) { var term = mod_pty.spawn('node', ['./test/getpass.js'], { name: 'xterm', cwd: process.cwd(), env: process.env }); var buf = ''; term.on('data', waitPrompt); function waitPrompt(data) { buf += data; if (buf === 'Password:') { buf = ''; term.write('a'); term.write('b'); term.write('c123'); setTimeout(function () { t.strictEqual(buf.length, 0); term.removeListener('data', waitPrompt); term.on('data', waitReply); term.write('\r'); term.end(); }, 100); } } function waitReply(data) { buf += data; } term.on('close', function () { t.strictEqual(buf.slice(0, 3), '\r\r\n'); buf = buf.slice(2); var payload = JSON.parse(buf); t.strictEqual(payload.error, null); t.strictEqual(payload.password, 'YWJjMTIz'); t.end(); }); }); node-getpass-0.1.7/test/getpass.js000066400000000000000000000026211307775715200171120ustar00rootroot00000000000000/* * Copyright 2016, Joyent, Inc. All rights reserved. * Author: Alex Wilson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ const mod_getpass = require('../lib/index'); mod_getpass.getPass(function (err, password) { var pwb64; if (!err) pwb64 = (new Buffer(password, 'utf8')).toString('base64'); console.log(JSON.stringify({error: err, password: pwb64})); }); node-getpass-0.1.7/tools/000077500000000000000000000000001307775715200152665ustar00rootroot00000000000000node-getpass-0.1.7/tools/bashstyle000066400000000000000000000072271307775715200172170ustar00rootroot00000000000000#!/usr/bin/env node /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* * Copyright (c) 2014, Joyent, Inc. */ /* * bashstyle: check bash scripts for adherence to style guidelines, including: * * o no lines longer than 80 characters * o file does not end with a blank line * o Do not use 'local' and var initialization *using a subshell* in the * same statement. See * * for why not. Arguably this belongs in a separate 'bashlint'. * * Future enhancements could include: * o indents consistent with respect to tabs, spaces * o indents consistently sized (all are some multiple of the smallest * indent, which must be a tab or 4 or 8 spaces) */ var VERSION = '2.0.0'; var mod_assert = require('assert'); var mod_fs = require('fs'); var nerrors = 0; main(); process.exit(0); function main() { var files = process.argv.slice(2); if (files.length === 0) { console.error('usage: %s file1 [...]', process.argv.slice(0, 2).join(' ')); process.exit(2); } files.forEach(checkFile); if (nerrors != 0) process.exit(1); } function checkFile(filename) { var text = mod_fs.readFileSync(filename, 'utf-8'); var lines = text.split('\n'); var i; var styled = false; var styleStart; mod_assert.ok(lines.length > 0); /* * Expand tabs in each line and check for long lines. */ for (i = 1; i <= lines.length; i++) { var line = expandTabs(lines[i - 1]); if (i > 1 && lines[i-2].match(/# BASHSTYLED/)) { continue; } if (line.match(/# BEGIN BASHSTYLED/)) { styleStart = i; styled = true; } if (line.match(/# END BASHSTYLED/)) { if (styled != true) { nerrors++; console.log('%s: %d: END BASHSTYLED w/o corresponding BEGIN', filename, i); } styled = false; } if (!styled && line.match(/^\s*local\s+(\w+)\s*=.*\$\(/)) { nerrors++; var m = line.match(/^\s*local\s+(\w+)\s*=/); console.log('%s: %d: declaring and setting a "local" ' + 'var in the same statement ' + 'ignores a subshell return code ' + ': ' + 'local %s=...', filename, i, m[1]); } // Regexplanation: non-[, [, space (contents) space, ], non-] // groups before and after brackets to ease search/replace. if (!styled && line.match(/(^|[^\[])\[(\s.+\s)\]([^\]])/)) { nerrors++; console.log('%s: %d: prefer [[ to [ for tests.', filename, i); } if (!styled && line.length > 80) { nerrors++; console.log('%s: %d: line exceeds 80 columns', filename, i); } } if (styled) { nerrors++; console.log('%s: %d: BEGIN BASHSTYLED that does not END', filename, styleStart); } /* * No sane editor lets you save a file without a newline at the very end. */ if (lines[lines.length - 1].length !== 0) { nerrors++; console.log('%s: %d: file does not end with newline', filename, lines.length); } /* * Since the file will always end with a newline, the last entry of * "lines" will actually be blank. */ if (lines.length > 1 && lines[lines.length - 2].length === 0) { nerrors++; console.log('%s: %d: file ends with a blank line', filename, lines.length - 1); } } function expandTabs(text) { var out = ''; var col = 0; var j, k; for (j = 0; j < text.length; j++) { if (text[j] != '\t') { out += text[j]; col++; continue; } k = 8 - (col % 8); col += k; do { out += ' '; } while (--k > 0); col += k; } return (out); } node-getpass-0.1.7/tools/jsl.node.conf000066400000000000000000000161611307775715200176560ustar00rootroot00000000000000# # Configuration File for JavaScript Lint # # This configuration file can be used to lint a collection of scripts, or to enable # or disable warnings for scripts that are linted via the command line. # ### Warnings # Enable or disable warnings based on requirements. # Use "+WarningName" to display or "-WarningName" to suppress. # +ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent +ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity +ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement +anon_no_return_value # anonymous function does not always return value +assign_to_function_call # assignment to a function call -block_without_braces # block statement without curly braces +comma_separated_stmts # multiple statements separated by commas (use semicolons?) +comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==) +default_not_at_end # the default case is not at the end of the switch statement +dup_option_explicit # duplicate "option explicit" control comment +duplicate_case_in_switch # duplicate case in switch statement +duplicate_formal # duplicate formal argument {name} +empty_statement # empty statement or extra semicolon +identifier_hides_another # identifer {name} hides an identifier in a parent scope -inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement +incorrect_version # Expected /*jsl:content-type*/ control comment. The script was parsed with the wrong version. +invalid_fallthru # unexpected "fallthru" control comment +invalid_pass # unexpected "pass" control comment +jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax +leading_decimal_point # leading decimal point may indicate a number or an object member +legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax +meaningless_block # meaningless block; curly braces have no impact +mismatch_ctrl_comments # mismatched control comment; "ignore" and "end" control comments must have a one-to-one correspondence +misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma +missing_break # missing break statement +missing_break_for_last_case # missing break statement for last case in switch +missing_default_case # missing default case in switch statement +missing_option_explicit # the "option explicit" control comment is missing +missing_semicolon # missing semicolon +missing_semicolon_for_lambda # missing semicolon for lambda assignment +multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs +nested_comment # nested comment +no_return_value # function {name} does not always return a value +octal_number # leading zeros make an octal number +parseint_missing_radix # parseInt missing radix parameter +partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag +redeclared_var # redeclaration of {name} +trailing_comma_in_array # extra comma is not recommended in array initializers +trailing_decimal_point # trailing decimal point may indicate a number or an object member +undeclared_identifier # undeclared identifier: {name} +unreachable_code # unreachable code -unreferenced_argument # argument declared but never referenced: {name} -unreferenced_function # function is declared but never referenced: {name} +unreferenced_variable # variable is declared but never referenced: {name} +unsupported_version # JavaScript {version} is not supported +use_of_label # use of label +useless_assign # useless assignment +useless_comparison # useless comparison; comparing identical expressions -useless_quotes # the quotation marks are unnecessary +useless_void # use of the void type may be unnecessary (void is always undefined) +var_hides_arg # variable {name} hides argument +want_assign_or_call # expected an assignment or function call +with_statement # with statement hides undeclared variables; use temporary variable instead ### Output format # Customize the format of the error message. # __FILE__ indicates current file path # __FILENAME__ indicates current file name # __LINE__ indicates current line # __COL__ indicates current column # __ERROR__ indicates error message (__ERROR_PREFIX__: __ERROR_MSG__) # __ERROR_NAME__ indicates error name (used in configuration file) # __ERROR_PREFIX__ indicates error prefix # __ERROR_MSG__ indicates error message # # For machine-friendly output, the output format can be prefixed with # "encode:". If specified, all items will be encoded with C-slashes. # # Visual Studio syntax (default): +output-format __FILE__(__LINE__): __ERROR__ # Alternative syntax: #+output-format __FILE__:__LINE__: __ERROR__ ### Context # Show the in-line position of the error. # Use "+context" to display or "-context" to suppress. # +context ### Control Comments # Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for # the /*@keyword@*/ control comments and JScript conditional comments. (The latter is # enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason, # although legacy control comments are enabled by default for backward compatibility. # -legacy_control_comments ### Defining identifiers # By default, "option explicit" is enabled on a per-file basis. # To enable this for all files, use "+always_use_option_explicit" -always_use_option_explicit # Define certain identifiers of which the lint is not aware. # (Use this in conjunction with the "undeclared identifier" warning.) # # Common uses for webpages might be: +define __dirname +define clearInterval +define clearTimeout +define console +define exports +define global +define module +define process +define require +define setInterval +define setTimeout +define setImmediate +define clearImmediate +define Buffer +define JSON +define Math # ES6 Typed Arrays +define ArrayBuffer +define DataView +define Int8Array +define Uint8Array +define Uint8ClampedArray +define Int16Array +define Uint16Array +define Int32Array +define Uint32Array +define Float32Array +define Float64Array ### JavaScript Version # To change the default JavaScript version: #+default-type text/javascript;version=1.5 #+default-type text/javascript;e4x=1 ### Files # Specify which files to lint # Use "+recurse" to enable recursion (disabled by default). # To add a set of files, use "+process FileName", "+process Folder\Path\*.js", # or "+process Folder\Path\*.htm". # node-getpass-0.1.7/tools/jsstyle.conf000066400000000000000000000004331307775715200176320ustar00rootroot00000000000000# # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # indent=tab blank-after-start-comment=0 node-getpass-0.1.7/tools/mk/000077500000000000000000000000001307775715200156755ustar00rootroot00000000000000node-getpass-0.1.7/tools/mk/Makefile.defs000066400000000000000000000032301307775715200202530ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.defs: common defines. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # # This makefile defines some useful defines. Include it at the top of # your Makefile. # # Definitions in this Makefile: # # TOP The absolute path to the project directory. The top dir. # BRANCH The current git branch. # TIMESTAMP The timestamp for the build. This can be set via # the TIMESTAMP envvar (used by MG-based builds). # STAMP A build stamp to use in built package names. # TOP := $(shell pwd) # # Mountain Gorilla-spec'd versioning. # See "Package Versioning" in MG's README.md: # # # Need GNU awk for multi-char arg to "-F". _AWK := $(shell (which gawk >/dev/null && echo gawk) \ || (which nawk >/dev/null && echo nawk) \ || echo awk) BRANCH := $(shell git symbolic-ref HEAD | $(_AWK) -F/ '{print $$3}') ifeq ($(TIMESTAMP),) TIMESTAMP := $(shell date -u "+%Y%m%dT%H%M%SZ") endif _GITDESCRIBE := g$(shell git describe --all --long --dirty | $(_AWK) -F'-g' '{print $$NF}') STAMP := $(BRANCH)-$(TIMESTAMP)-$(_GITDESCRIBE) # node-gyp will print build info useful for debugging with V=1 export V=1 node-getpass-0.1.7/tools/mk/Makefile.deps000066400000000000000000000025111307775715200202660ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.deps: Makefile for including common tools as dependencies # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # # This file is separate from Makefile.targ so that teams can choose # independently whether to use the common targets in Makefile.targ and the # common tools here. # # # javascriptlint # JSL_EXEC ?= deps/javascriptlint/build/install/jsl JSL ?= $(JSL_EXEC) $(JSL_EXEC): | deps/javascriptlint/.git cd deps/javascriptlint && make install distclean:: if [[ -f deps/javascriptlint/Makefile ]]; then \ cd deps/javascriptlint && make clean; \ fi # # jsstyle # JSSTYLE_EXEC ?= deps/jsstyle/jsstyle JSSTYLE ?= $(JSSTYLE_EXEC) $(JSSTYLE_EXEC): | deps/jsstyle/.git # # restdown # RESTDOWN_EXEC ?= deps/restdown/bin/restdown RESTDOWN ?= python $(RESTDOWN_EXEC) $(RESTDOWN_EXEC): | deps/restdown/.git EXTRA_DOC_DEPS ?= node-getpass-0.1.7/tools/mk/Makefile.node.defs000066400000000000000000000100101307775715200211710ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.node.defs: Makefile for building and bundling your own Node.js. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # # # This Makefile facilitates building and bundling your own copy of Node.js in # your repo. All it does is define variables for node, node-waf, and npm for # you to use elsewhere in your Makefile and rules to build these tools when # needed. # # To use this facility, include "Makefile.node.defs", use the variables as # described below to define targets, and then include "Makefile.node.targ". # # There are two use cases addressed here: # # (1) Invoking node, node-waf, or npm as part of the build process, as in "npm # install" and "node-waf configure build". To facilitate this, this # Makefile defines Make variables NODE, NODE_WAF, and NPM that you can use # to invoke these commands during the build process. You MUST NOT assume # that these variables just evaluate to the filenames themselves, as they # may have environment variable definitions and other things that prevent # you from using them directly as a filename. If you want that, see (2). # # Wherever you use one of these variables, you MUST include a dependency on # the corresponding *_EXEC variable as well, like so: # # node_modules/restify: deps/restify $(NPM_EXEC) # $(NPM) install deps/restify # # or better, use an order-only dependency to avoid spurious rebuilds: # # node_modules/restify: deps/restify | $(NPM_EXEC) # $(NPM) install deps/restify # # Otherwise, the underlying file will not get built. We don't # automatically build them as part of "all" because that approach is # brittle. # # (2) Specifying paths for invoking node, node-waf, or npm at RUNTIME, as in # specifying the path to node used for the start method of your service's # SMF manifest. For this, this Makefile defines variables NODE_EXEC, # NODE_WAF_EXEC, and NPM_EXEC, which represent the relative paths of these # files from the root of the workspace. You MUST NOT use these variables # to invoke these commands during the build process. See (1) instead. # # However, in order to work at runtime, you must build the tool as well. # That is, if you use NODE_EXEC to specify the path to node, you must # depend on NODE_EXEC somewhere. This usually happens anyway because you # usually need them during the build process too, but if you don't then # you need to explicitly add NODE_EXEC (or whichever) to your "all" # target. # # When including this Makefile, you MAY also specify: # # BUILD top-level directory for built binaries # (default: "build") # # NODE_INSTALL where node should install its built items # (default: "$BUILD/node") # # NODE_CONFIG_FLAGS extra flags to pass to Node's "configure" # (default: "--with-dtrace" on SmartOS; empty # otherwise.) # TOP ?= $(error You must include Makefile.defs before this makefile) BUILD ?= build NODE_INSTALL ?= $(BUILD)/node DISTCLEAN_FILES += $(NODE_INSTALL) NODE_CONFIG_FLAGS += --prefix=$(TOP)/$(NODE_INSTALL) ifeq ($(shell uname -s),SunOS) NODE_CONFIG_FLAGS += --with-dtrace \ --openssl-libpath=/opt/local/lib \ --openssl-includes=/opt/local/include endif NODE_EXEC = $(NODE_INSTALL)/bin/node NODE_WAF_EXEC = $(NODE_INSTALL)/bin/node-waf NPM_EXEC = $(NODE_INSTALL)/bin/npm # Ensure these use absolute paths to the executables to allow running # from a dir other than the project top. NODE := $(TOP)/$(NODE_EXEC) NODE_WAF := $(TOP)/$(NODE_WAF_EXEC) NPM := PATH=$(TOP)/$(NODE_INSTALL)/bin:$(PATH) node $(TOP)/$(NPM_EXEC) node-getpass-0.1.7/tools/mk/Makefile.node.targ000066400000000000000000000026251307775715200212220ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.node.targ: See Makefile.node.defs. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # ifneq ($(shell uname -s),SunOS) NODE_PREBUILT_VERSION ?= $(error You must define NODE_PREBUILT_VERSION to use Makefile.node.targ on non-SunOS) endif ifeq ($(shell uname -s),SunOS) $(NODE_EXEC) $(NPM_EXEC) $(NODE_WAF_EXEC): | deps/node/.git (cd deps/node; ./configure $(NODE_CONFIG_FLAGS) && $(MAKE) && $(MAKE) install) else $(NODE_EXEC) $(NPM_EXEC) $(NODE_WAF_EXEC): (mkdir -p $(BUILD) \ && cd $(BUILD) \ && [[ -d src-node ]] && (cd src-node && git checkout master && git pull) || git clone https://github.com/joyent/node.git src-node \ && cd src-node \ && git checkout $(NODE_PREBUILT_VERSION) \ && ./configure $(NODE_CONFIG_FLAGS) \ && $(MAKE) && $(MAKE) install) endif DISTCLEAN_FILES += $(NODE_INSTALL) $(BUILD)/src-node distclean:: -([[ ! -d deps/node ]] || (cd deps/node && $(MAKE) distclean)) node-getpass-0.1.7/tools/mk/Makefile.node_deps.defs000066400000000000000000000031151307775715200222140ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.node_deps.defs: Makefile for including npm modules whose sources # reside inside the repo. This should NOT be used for modules in the npm # public repo or modules that could be specified with git SHAs. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # # # This Makefile takes as input the following make variable: # # REPO_MODULES List of relative paths to node modules (i.e., npm # packages) inside this repo. For example: # src/node-canative, where there's a binary npm package # in src/node-canative. # # Based on the above, this Makefile defines the following new variables: # # REPO_DEPS List of relative paths to the installed modules. For # example: "node_modules/canative". # # The accompanying Makefile.node_deps.targ defines a target that will install # each of REPO_MODULES into REPO_DEPS and remove REPO_DEPS with "make clean". # The top-level Makefile is responsible for depending on REPO_DEPS where # appropriate (usually the "deps" or "all" target). # REPO_DEPS = $(REPO_MODULES:src/node-%=node_modules/%) CLEAN_FILES += $(REPO_DEPS) node-getpass-0.1.7/tools/mk/Makefile.node_deps.targ000066400000000000000000000013751307775715200222360ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.node_deps.targ: targets for Makefile.node_deps.defs. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # NPM_EXEC ?= $(error NPM_EXEC must be defined for Makefile.node_deps.targ) node_modules/%: src/node-% | $(NPM_EXEC) $(NPM) install $< node-getpass-0.1.7/tools/mk/Makefile.node_prebuilt.defs000066400000000000000000000140451307775715200231130ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.node_prebuilt.defs: Makefile for including a prebuilt Node.js build. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # # # This Makefile facilitates downloading and bundling a prebuilt node.js # build (using the 'sdcnode' distro builds). This is an alternative to # the "Makefile.node.*" makefiles for *building* a node from source. # # Usage: # # - Define `NODE_PREBUILT_VERSION` in your Makefile to choose a node version. # E.g.: `NODE_PREBUILT_VERSION=v0.6.19`. See other optional variables # below. # - `include tools/mk/Makefile.node_prebuilt.defs` after this in your Makefile. # - `include tools/mk/Makefile.node_prebuilt.targ` near the end of your # Makefile. # - Have at least one of your Makefile targets depend on either `$(NODE_EXEC)` # or `$(NPM_EXEC)`. E.g.: # # node_modules/restify: deps/restify $(NPM_EXEC) # $(NPM) install deps/restify # # or better, use an order-only dependency to avoid spurious rebuilds: # # node_modules/restify: deps/restify | $(NPM_EXEC) # $(NPM) install deps/restify # # - Use `$(NPM)` or `$(NODE)` to use your node build. # - Include the "$(NODE_INSTALL)" tree in your release package. # # # When including this Makefile, you MUST also specify: # # NODE_PREBUILT_VERSION The node version in the prebuilt 'sdcnode' # package to use. Typically this is one of the # node version tags, e.g. "v0.6.18" but it # can be any commitish. # # When including this Makefile, you MAY also specify: # # NODE_PREBUILT_DIR The dir in which to find sdcnode builds. This # can either be a *local directory* or *a # URL* dir (with trailing '/') which serves # Apache/Nginx dir listing HTML. # (default: sdcnode master build dir on stuff) # # NODE_PREBUILT_TAG The 'sdcnode' project supports special # configuration builds of node, e.g. say a # build configured `--without-ssl`. These # special configurations are given a tag, e.g. # 'gz', that is used in the filename. Optionally # specify a tag name here. # (default: empty) # # NODE_PREBUILT_BRANCH Specify a particular branch of 'sdcnode' builds # from which to pull. Generally one should stick # with the default. # (default: master) # # NODE_PREBUILT_IMAGE If you have a zone image that differs from that # for an sdcnode build that you want to use (potential compat # issues be damned), then set this to the UUID of the sdcnode # build you want. See here for available build image uuids: # # # BUILD top-level directory for built binaries # (default: "build") # # NODE_INSTALL where node should install its built items # (default: "$BUILD/node") # # # Dev Notes: # # This works by getting "NODE_PREBUILT_NAME" from the provided "NODE_PREBUILT_*" # vars and the image version (via 'mdata-get sdc:image_uuid'). The image uuid is # included to ensure an exact match with the build machine. This name (e.g. # "v0.6.18-zone-$uuid") is used to find a matching "sdcnode-$name-*.tgz" build # in "NODE_PREBUILT_DIR" (either a local directory or a URL). That tarball is # downloaded and extracted into "NODE_INSTALL". # # The "*_EXEC" vars are set to named symlinks, e.g. # "build/prebuilt-node-v0.6.18-$uuid", so that a change of selected node # build (say the developer changes NODE_PREBUILT_VERSION) will recreate the # node install. # # See for details on 'sdcnode-*' # package naming. # TOP ?= $(error You must include Makefile.defs before this makefile) NODE_PREBUILT_VERSION ?= $(error NODE_PREBUILT_VERSION is not set.) BUILD ?= build NODE_INSTALL ?= $(BUILD)/node DISTCLEAN_FILES += $(NODE_INSTALL) \ $(BUILD)/prebuilt-node-* $(BUILD)/prebuilt-npm-* NODE_PREBUILT_BRANCH ?= master NODE_PREBUILT_IMAGE ?= $(shell pfexec mdata-get sdc:image_uuid) ifeq ($(NODE_PREBUILT_TAG),) NODE_PREBUILT_NAME := $(NODE_PREBUILT_VERSION)-$(NODE_PREBUILT_IMAGE) else NODE_PREBUILT_NAME := $(NODE_PREBUILT_VERSION)-$(NODE_PREBUILT_TAG)-$(NODE_PREBUILT_IMAGE) endif NODE_PREBUILT_PATTERN := sdcnode-$(NODE_PREBUILT_NAME)-$(NODE_PREBUILT_BRANCH)-.*\.tgz NODE_PREBUILT_DIR ?= https://download.joyent.com/pub/build/sdcnode/$(NODE_PREBUILT_IMAGE)/$(NODE_PREBUILT_BRANCH)-latest/sdcnode/ ifeq ($(shell echo $(NODE_PREBUILT_DIR) | cut -c 1-4),http) NODE_PREBUILT_BASE := $(shell curl -ksS --fail --connect-timeout 30 $(NODE_PREBUILT_DIR) | grep 'href=' | cut -d'"' -f2 | grep "^$(NODE_PREBUILT_PATTERN)$$" | sort | tail -1) ifneq ($(NODE_PREBUILT_BASE),) NODE_PREBUILT_TARBALL := $(NODE_PREBUILT_DIR)$(NODE_PREBUILT_BASE) endif else NODE_PREBUILT_BASE := $(shell ls -1 $(NODE_PREBUILT_DIR)/ | grep "^$(NODE_PREBUILT_PATTERN)$$" 2>/dev/null | sort | tail -1) ifneq ($(NODE_PREBUILT_BASE),) NODE_PREBUILT_TARBALL := $(NODE_PREBUILT_DIR)/$(NODE_PREBUILT_BASE) endif endif ifeq ($(NODE_PREBUILT_TARBALL),) NODE_PREBUILT_TARBALL = $(error NODE_PREBUILT_TARBALL is empty: no '$(NODE_PREBUILT_DIR)/$(NODE_PREBUILT_PATTERN)' found) endif # Prebuild-specific paths for the "*_EXEC" vars to ensure that # a prebuild change (e.g. if master Makefile's NODE_PREBUILT_VERSION # choice changes) causes a install of the new node. NODE_EXEC := $(BUILD)/prebuilt-node-$(NODE_PREBUILT_NAME) NODE_WAF_EXEC := $(BUILD)/prebuilt-node-waf-$(NODE_PREBUILT_NAME) NPM_EXEC := $(BUILD)/prebuilt-npm-$(NODE_PREBUILT_NAME) # Ensure these use absolute paths to the executables to allow running # from a dir other than the project top. NODE := $(TOP)/$(NODE_INSTALL)/bin/node NODE_WAF := $(TOP)/$(NODE_INSTALL)/bin/node-waf NPM := PATH=$(TOP)/$(NODE_INSTALL)/bin:$(PATH) node $(TOP)/$(NODE_INSTALL)/bin/npm node-getpass-0.1.7/tools/mk/Makefile.node_prebuilt.targ000066400000000000000000000033131307775715200231230ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.node_prebuilt.targ: Makefile for including a prebuilt Node.js # build. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. NODE_PREBUILT_TARBALL ?= $(error NODE_PREBUILT_TARBALL is not set: was Makefile.node_prebuilt.defs included?) # TODO: remove this limitation # Limitation: currently presuming that the NODE_INSTALL basename is # 'node' and that sdcnode tarballs have a 'node' top-level dir. $(NODE_EXEC) $(NPM_EXEC) $(NODE_WAF_EXEC): [[ $(shell basename $(NODE_INSTALL)) == "node" ]] \ || (echo "Limitation: 'basename NODE_INSTALL' is not 'node'" && exit 1) rm -rf $(NODE_INSTALL) \ $(BUILD)/prebuilt-node-* $(BUILD)/prebuilt-npm-* mkdir -p $(shell dirname $(NODE_INSTALL)) if [[ $(shell echo $(NODE_PREBUILT_TARBALL) | cut -c 1-4) == "http" ]]; then \ echo "Downloading '$(NODE_PREBUILT_BASE)'."; \ curl -ksS --fail --connect-timeout 30 -o $(shell dirname $(NODE_INSTALL))/$(NODE_PREBUILT_BASE) $(NODE_PREBUILT_TARBALL); \ (cd $(shell dirname $(NODE_INSTALL)) && $(TAR) xf $(NODE_PREBUILT_BASE)); \ else \ (cd $(shell dirname $(NODE_INSTALL)) && $(TAR) xf $(NODE_PREBUILT_TARBALL)); \ fi ln -s $(TOP)/$(NODE_INSTALL)/bin/node $(NODE_EXEC) ln -s $(TOP)/$(NODE_INSTALL)/bin/npm $(NPM_EXEC) node-getpass-0.1.7/tools/mk/Makefile.targ000066400000000000000000000226121307775715200202740ustar00rootroot00000000000000# -*- mode: makefile -*- # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # # Copyright (c) 2014, Joyent, Inc. # # # Makefile.targ: common targets. # # NOTE: This makefile comes from the "eng" repo. It's designed to be dropped # into other repos as-is without requiring any modifications. If you find # yourself changing this file, you should instead update the original copy in # eng.git and then update your repo to use the new version. # # This Makefile defines several useful targets and rules. You can use it by # including it from a Makefile that specifies some of the variables below. # # Targets defined in this Makefile: # # check Checks JavaScript files for lint and style # Checks bash scripts for syntax # Checks SMF manifests for validity against the SMF DTD # # clean Removes built files # # docs Builds restdown documentation in docs/ # # prepush Depends on "check" and "test" # # test Does nothing (you should override this) # # xref Generates cscope (source cross-reference index) # # For details on what these targets are supposed to do, see the Joyent # Engineering Guide. # # To make use of these targets, you'll need to set some of these variables. Any # variables left unset will simply not be used. # # BASH_FILES Bash scripts to check for syntax # (paths relative to top-level Makefile) # # CLEAN_FILES Files to remove as part of the "clean" target. Note # that files generated by targets in this Makefile are # automatically included in CLEAN_FILES. These include # restdown-generated HTML and JSON files. # # DOC_FILES Restdown (documentation source) files. These are # assumed to be contained in "docs/", and must NOT # contain the "docs/" prefix. # # JSL_CONF_NODE Specify JavaScriptLint configuration files # JSL_CONF_WEB (paths relative to top-level Makefile) # # Node.js and Web configuration files are separate # because you'll usually want different global variable # configurations. If no file is specified, none is given # to jsl, which causes it to use a default configuration, # which probably isn't what you want. # # JSL_FILES_NODE JavaScript files to check with Node config file. # JSL_FILES_WEB JavaScript files to check with Web config file. # # JSON_FILES JSON files to be validated # # JSSTYLE_FILES JavaScript files to be style-checked # # You can also override these variables: # # BASH Path to bash (default: "bash") # # CSCOPE_DIRS Directories to search for source files for the cscope # index. (default: ".") # # JSL Path to JavaScriptLint (default: "jsl") # # JSL_FLAGS_NODE Additional flags to pass through to JSL # JSL_FLAGS_WEB # JSL_FLAGS # # JSON Path to json tool (default: "json") # # JSSTYLE Path to jsstyle (default: "jsstyle") # # JSSTYLE_FLAGS Additional flags to pass through to jsstyle # # RESTDOWN_EXT By default '.md' is required for DOC_FILES (see above). # If you want to use, say, '.restdown' instead, then set # 'RESTDOWN_EXT=.restdown' in your Makefile. # # # Defaults for the various tools we use. # BASH ?= bash BASHSTYLE ?= tools/bashstyle CP ?= cp CSCOPE ?= cscope CSCOPE_DIRS ?= . JSL ?= jsl JSON ?= json JSSTYLE ?= jsstyle MKDIR ?= mkdir -p MV ?= mv RESTDOWN_FLAGS ?= RESTDOWN_EXT ?= .md RMTREE ?= rm -rf JSL_FLAGS ?= --nologo --nosummary ifeq ($(shell uname -s),SunOS) TAR ?= gtar else TAR ?= tar endif # # Defaults for other fixed values. # BUILD = build DISTCLEAN_FILES += $(BUILD) DOC_BUILD = $(BUILD)/docs/public # # Configure JSL_FLAGS_{NODE,WEB} based on JSL_CONF_{NODE,WEB}. # ifneq ($(origin JSL_CONF_NODE), undefined) JSL_FLAGS_NODE += --conf=$(JSL_CONF_NODE) endif ifneq ($(origin JSL_CONF_WEB), undefined) JSL_FLAGS_WEB += --conf=$(JSL_CONF_WEB) endif # # Targets. For descriptions on what these are supposed to do, see the # Joyent Engineering Guide. # # # Instruct make to keep around temporary files. We have rules below that # automatically update git submodules as needed, but they employ a deps/*/.git # temporary file. Without this directive, make tries to remove these .git # directories after the build has completed. # .SECONDARY: $($(wildcard deps/*):%=%/.git) # # This rule enables other rules that use files from a git submodule to have # those files depend on deps/module/.git and have "make" automatically check # out the submodule as needed. # deps/%/.git: git submodule update --init deps/$* # # These recipes make heavy use of dynamically-created phony targets. The parent # Makefile defines a list of input files like BASH_FILES. We then say that each # of these files depends on a fake target called filename.bashchk, and then we # define a pattern rule for those targets that runs bash in check-syntax-only # mode. This mechanism has the nice properties that if you specify zero files, # the rule becomes a noop (unlike a single rule to check all bash files, which # would invoke bash with zero files), and you can check individual files from # the command line with "make filename.bashchk". # .PHONY: check-bash check-bash: $(BASH_FILES:%=%.bashchk) $(BASH_FILES:%=%.bashstyle) %.bashchk: % $(BASH) -n $^ %.bashstyle: % $(BASHSTYLE) $^ .PHONY: check-json check-json: $(JSON_FILES:%=%.jsonchk) %.jsonchk: % $(JSON) $(JSON) --validate -f $^ # # The above approach can be slow when there are many files to check because it # requires that "make" invoke the check tool once for each file, rather than # passing in several files at once. For the JavaScript check targets, we define # a variable for the target itself *only if* the list of input files is # non-empty. This avoids invoking the tool if there are no files to check. # JSL_NODE_TARGET = $(if $(JSL_FILES_NODE), check-jsl-node) .PHONY: check-jsl-node check-jsl-node: $(JSL_EXEC) $(JSL) $(JSL_FLAGS) $(JSL_FLAGS_NODE) $(JSL_FILES_NODE) JSL_WEB_TARGET = $(if $(JSL_FILES_WEB), check-jsl-web) .PHONY: check-jsl-web check-jsl-web: $(JSL_EXEC) $(JSL) $(JSL_FLAGS) $(JSL_FLAGS_WEB) $(JSL_FILES_WEB) .PHONY: check-jsl check-jsl: $(JSL_NODE_TARGET) $(JSL_WEB_TARGET) JSSTYLE_TARGET = $(if $(JSSTYLE_FILES), check-jsstyle) .PHONY: check-jsstyle check-jsstyle: $(JSSTYLE_EXEC) $(JSSTYLE) $(JSSTYLE_FLAGS) $(JSSTYLE_FILES) .PHONY: check check:: check-jsl check-json $(JSSTYLE_TARGET) check-bash @echo check ok .PHONY: clean clean:: -$(RMTREE) $(CLEAN_FILES) .PHONY: distclean distclean:: clean -$(RMTREE) $(DISTCLEAN_FILES) CSCOPE_FILES = cscope.in.out cscope.out cscope.po.out CLEAN_FILES += $(CSCOPE_FILES) .PHONY: xref xref: cscope.files $(CSCOPE) -bqR .PHONY: cscope.files cscope.files: find $(CSCOPE_DIRS) -name '*.c' -o -name '*.h' -o -name '*.cc' \ -o -name '*.js' -o -name '*.s' -o -name '*.cpp' > $@ # # The "docs" target is complicated because we do several things here: # # (1) Use restdown to build HTML and JSON files from each of DOC_FILES. # # (2) Copy these files into $(DOC_BUILD) (build/docs/public), which # functions as a complete copy of the documentation that could be # mirrored or served over HTTP. # # (3) Then copy any directories and media from docs/media into # $(DOC_BUILD)/media. This allows projects to include their own media, # including files that will override same-named files provided by # restdown. # # Step (3) is the surprisingly complex part: in order to do this, we need to # identify the subdirectories in docs/media, recreate them in # $(DOC_BUILD)/media, then do the same with the files. # DOC_MEDIA_DIRS := $(shell find docs/media -type d 2>/dev/null | grep -v "^docs/media$$") DOC_MEDIA_DIRS := $(DOC_MEDIA_DIRS:docs/media/%=%) DOC_MEDIA_DIRS_BUILD := $(DOC_MEDIA_DIRS:%=$(DOC_BUILD)/media/%) DOC_MEDIA_FILES := $(shell find docs/media -type f 2>/dev/null) DOC_MEDIA_FILES := $(DOC_MEDIA_FILES:docs/media/%=%) DOC_MEDIA_FILES_BUILD := $(DOC_MEDIA_FILES:%=$(DOC_BUILD)/media/%) # # Like the other targets, "docs" just depends on the final files we want to # create in $(DOC_BUILD), leveraging other targets and recipes to define how # to get there. # .PHONY: docs docs:: \ $(DOC_FILES:%$(RESTDOWN_EXT)=$(DOC_BUILD)/%.html) \ $(DOC_FILES:%$(RESTDOWN_EXT)=$(DOC_BUILD)/%.json) \ $(DOC_MEDIA_FILES_BUILD) # # We keep the intermediate files so that the next build can see whether the # files in DOC_BUILD are up to date. # .PRECIOUS: \ $(DOC_FILES:%$(RESTDOWN_EXT)=docs/%.html) \ $(DOC_FILES:%$(RESTDOWN_EXT)=docs/%json) # # We do clean those intermediate files, as well as all of DOC_BUILD. # CLEAN_FILES += \ $(DOC_BUILD) \ $(DOC_FILES:%$(RESTDOWN_EXT)=docs/%.html) \ $(DOC_FILES:%$(RESTDOWN_EXT)=docs/%.json) # # Before installing the files, we must make sure the directories exist. The | # syntax tells make that the dependency need only exist, not be up to date. # Otherwise, it might try to rebuild spuriously because the directory itself # appears out of date. # $(DOC_MEDIA_FILES_BUILD): | $(DOC_MEDIA_DIRS_BUILD) $(DOC_BUILD)/%: docs/% | $(DOC_BUILD) $(MKDIR) $(shell dirname $@) $(CP) $< $@ docs/%.json docs/%.html: docs/%$(RESTDOWN_EXT) | $(DOC_BUILD) $(RESTDOWN_EXEC) \ $(EXTRA_DOC_DEPS) $(RESTDOWN) $(RESTDOWN_FLAGS) -m $(DOC_BUILD) $< $(DOC_BUILD): $(MKDIR) $@ $(DOC_MEDIA_DIRS_BUILD): $(MKDIR) $@ # # The default "test" target does nothing. This should usually be overridden by # the parent Makefile. It's included here so we can define "prepush" without # requiring the repo to define "test". # .PHONY: test test: .PHONY: prepush prepush: check test