├── .gitignore ├── .travis.yml ├── LICENSE.md ├── README.md ├── bin └── upgrade-utils ├── index.js ├── lib ├── assets │ ├── editor.css │ ├── logo-white.svg │ └── markdownPreview.css ├── docs │ ├── assert.md │ ├── buffer.md │ ├── child_process.md │ ├── cluster.md │ ├── crypto.md │ ├── dgram.md │ ├── domain.md │ ├── events.md │ ├── freelist.md │ ├── fs.md │ ├── http.md │ ├── net.md │ ├── os.md │ ├── path.md │ ├── process.md │ ├── querystring.md │ ├── smalloc.md │ ├── stream.md │ ├── sys.md │ ├── timers.md │ ├── tls.md │ ├── url.md │ ├── util.md │ └── vm.md ├── replacements.js ├── suggestions.js └── template.hbs ├── package.json └── test ├── resources ├── test-changed.zip └── test-mod.zip ├── test-bin.js └── test-module.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | coverage 3 | /node_modules/ 4 | npm-debug.log 5 | upgrade-log.html 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - "stable" 5 | - "0.10" 6 | - "0.12" 7 | - "4" 8 | 9 | addons: 10 | apt: 11 | sources: 12 | - "ubuntu-toolchain-r-test" 13 | packages: 14 | - "g++-4.8" 15 | 16 | env: 17 | - "CXX=g++-4.8" 18 | 19 | before_install: 20 | - "$CXX --version" 21 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright (c) 2015 NodeSource 5 | ----------------------------- 6 | 7 | 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: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | 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. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # upgrade-utils 2 | 3 | **A tool from [NodeSource](https://nodesource.com/) to help with the process of upgrading modules to the latest version of Node.js latest Node version (currently v4), replacing old [NAN](https://github.com/nodejs/nan) C++ bindings and adjusting for Node.js API changes.** 4 | 5 | ## SYPNOSIS 6 | `upgrade-utils [-p ] [-e ] [OPTIONS]` 7 | 8 | ## DESCRIPTION 9 | Search, report and optionally replace changes in a module's code, helping in the process of updating to the latest Node version. 10 | 11 | ## USAGE 12 | Using with no parameters will search recursively by default in the current directory for files with extensions: .js, .cc .c .cpp .h and .hh, and will display required changes to apply in them in order to update the module to the latest version of Node and NAN. a log will generate will all the information in an HTML file opening this in a browser 13 | 14 | `upgrade-utils` 15 | 16 | You can customize the path where the command will act with *-p* or *--path* options 17 | 18 | `upgrade-utils -p /the/module/path` 19 | `upgrade-utils --path /the/module/path` 20 | 21 | You can customize the extensions to search for with *-e* or *--extensions* options and providing a coma separated list of extensions 22 | 23 | `upgrade-utils -e .c,.cpp,.cp` 24 | `upgrade-utils --extensions .c,.cpp,.cp` 25 | 26 | You can perform all changes in all files with *-u* or *--update* options 27 | 28 | `upgrade-utils -u` 29 | `upgrade-utils --update` 30 | 31 | You can avoid launching the browser with *-q* or *--quiet* 32 | 33 | `upgrade-utils -q` 34 | `upgrade-utils --quiet` 35 | 36 | ## Authors and Contributors 37 | 38 | 39 | 40 | 41 |
Adrián EstradaGitHub/edsadrTwitter/@edsadr
Julián DuqueGitHub/julianduqueTwitter/@julian_duque
42 | 43 | Contributions are welcomed from anyone wanting to improve this project! 44 | 45 | ## License & Copyright 46 | 47 | **upgrade-utils** is Copyright (c) 2015 NodeSource and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. 48 | -------------------------------------------------------------------------------- /bin/upgrade-utils: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var path = require('path') 4 | var upgradeUtils = require('../index.js') 5 | var msee = require('msee') 6 | var mseeOptions = { 7 | paragraphStart: '', 8 | paragraphEnd: '\n\n' 9 | } 10 | 11 | // Setting arguments 12 | var args = require('minimist')(process.argv.slice(2), { 13 | string: ['extensions', 'path'], 14 | boolean: ['help', 'quiet', 'update'], 15 | alias: { 16 | e: 'extensions', 17 | h: 'help', 18 | q: 'quiet', 19 | p: 'path', 20 | u: 'update' 21 | }, 22 | default: { 23 | e: '.c,.cc,.cpp,.h,.hh,.js', 24 | p: '.', 25 | q: false 26 | }, 27 | unknown: function (cmd) { 28 | console.error("'%s' is not a upgrade-utils option. " + "See 'upgrade-utils --help'.", cmd) 29 | process.exit(1) 30 | } 31 | }) 32 | 33 | if (args.help) { 34 | var help = msee.parseFile(path.resolve(__dirname, '..', 'README.md'), mseeOptions) 35 | console.log(help) 36 | process.exit(0) 37 | } 38 | 39 | upgradeUtils(args.path, args.update, args.extensions, args.quiet) 40 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var fs = require('graceful-fs') 2 | var async = require('async') 3 | var path = require('path') 4 | var diff = require('diff') 5 | var marked = require('marked') 6 | var chalk = require('chalk') 7 | var handlebars = require('handlebars') 8 | var opener = require('opener') 9 | 10 | var replacements = require('./lib/replacements.js')() 11 | var suggestions = require('./lib/suggestions.js')() 12 | var changed = [] 13 | var suggested = {} 14 | var dir, update, filters, quiet, callback 15 | 16 | // Function replacing all regex in a file and returning the new content 17 | var queue = async.queue(function (file, callback) { 18 | fs.readFile(file, 'utf-8', function (err, text) { 19 | if (err) { 20 | throw err 21 | } 22 | 23 | // Replacing text 24 | var content = replaceText(text, file) 25 | 26 | // Checking for changes 27 | if (content !== null) { 28 | var changes = diff.diffLines(text, content) 29 | changed.push({ 30 | file: file, 31 | changes: changes 32 | }) 33 | 34 | // Writing the file if update is true 35 | if (update) { 36 | fs.writeFile(file, content, function (err) { 37 | if (err) return callback(err) 38 | console.log('The file ' + file + ' was updated') 39 | return callback(null, file) 40 | }) 41 | } else { 42 | return callback(null, file) 43 | } 44 | } else { 45 | return callback(null, file) 46 | } 47 | }) 48 | }, 5) 49 | 50 | queue.drain = function () { 51 | printResults() 52 | } 53 | 54 | // Recursive function searching files and directories in a path to process files 55 | function searchFiles (file) { 56 | fs.lstat(file, function (err, stats) { 57 | if (err) throw err 58 | 59 | var isFile = stats.isFile() 60 | 61 | if (stats.isSymbolicLink()) { 62 | return 63 | } 64 | 65 | // Looking just for filtered extensions 66 | if (isFile && filters.indexOf(path.extname(file)) !== -1) { 67 | console.log('Processing ' + file) 68 | 69 | // Adding the file to the queue 70 | queue.push(file, function (err, cfile) { 71 | if (err) throw err 72 | }) 73 | } else if (stats.isDirectory() && file.indexOf('node_modules') === -1) { 74 | // Reading directories 75 | fs.readdir(file, function (err, files) { 76 | if (err) throw err 77 | for (var i = 0; i < files.length; i++) { 78 | // Avoid hidden files and directories 79 | if (/^[^.].*$/.test(files[i])) { 80 | searchFiles(path.join(file, files[i])) 81 | } 82 | } 83 | }) 84 | } 85 | }) 86 | } 87 | 88 | function replaceText (text, file) { 89 | // replacing all regexps 90 | var content = text 91 | 92 | // Checking for Nan replacements 93 | if (path.extname(file) !== '.js') { 94 | for (var i = 0; i < replacements.length; i++) { 95 | var exp = new RegExp(replacements[i].search, 'g') 96 | content = content.replace(exp, replacements[i].replace) 97 | } 98 | } 99 | 100 | // Checking for JS suggestions 101 | if (path.extname(file) === '.js') { 102 | for (var k = 0; k < suggestions.length; k++) { 103 | var regex = suggestions[k].exp || '([A-z0-9_]*)\s*=\s*require(?:\s*)\((\s*)(?:\'|"|)' + suggestions[k].subsystem + '(?:\'|"|\s*)(\s*)\)' 104 | var sug = new RegExp(regex, 'g') 105 | if (sug.test(text)) { 106 | var subsystem = suggestions[k].subsystem 107 | if (suggested[subsystem]) { 108 | suggested[subsystem].files.push(file) 109 | } else { 110 | suggested[subsystem] = { 111 | doc: subsystem, 112 | files: [file] 113 | } 114 | } 115 | } 116 | } 117 | } 118 | 119 | // Returning null if not changes 120 | if (content === text) { 121 | return null 122 | } 123 | 124 | return content 125 | } 126 | 127 | function printResults () { 128 | if (changed.length === 0 && Object.keys(suggested).length === 0) { 129 | console.log(chalk.green('Nothing to suggest or replace in the current path after looking for file extensions: ' + filters.join(', '))) 130 | if (callback) return callback() 131 | return 132 | } 133 | 134 | if (update) { 135 | var lastMessage = 'All your native files were changed, for the next step update your NAN dependency to the last version and and try building your module.' 136 | console.log(chalk.yellow(lastMessage)) 137 | } 138 | 139 | for (var sug in suggested) { 140 | if (suggested.hasOwnProperty(sug)) { 141 | var doc = path.resolve(__dirname, 'lib', 'docs', suggested[sug].doc + '.md') 142 | suggested[sug].content = marked(fs.readFileSync(doc, 'utf-8')) 143 | } 144 | } 145 | 146 | var source = fs.readFileSync(path.resolve(__dirname, 'lib', 'template.hbs'), 'utf-8') 147 | var template = handlebars.compile(source) 148 | 149 | handlebars.registerHelper('asset', function (filepath) { 150 | return path.join(__dirname, 'lib', 'assets', filepath).replace(/\\/g, '/') 151 | }) 152 | 153 | var html = template({diffs: changed, suggestions: suggested, update: update}) 154 | 155 | fs.writeFile(path.join(dir, 'upgrade-log.html'), html, function (err) { 156 | if (err) throw err 157 | console.log(chalk.green('\n The file upgrade-log.html was created and contains all changes')) 158 | if (!quiet) { 159 | opener(path.join(dir, 'upgrade-log.html')) 160 | } 161 | }) 162 | 163 | changed = [] 164 | suggested = [] 165 | 166 | if (callback) return callback() 167 | } 168 | 169 | module.exports = function (path, write, extensions, qlog, cb) { 170 | dir = path 171 | update = write 172 | quiet = qlog 173 | filters = extensions.split(',') 174 | callback = cb 175 | searchFiles(path) 176 | } 177 | -------------------------------------------------------------------------------- /lib/assets/editor.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin: 0; 3 | padding: 0; 4 | } 5 | 6 | body { 7 | background: #fff; 8 | color: #444; 9 | font-family: 'Source Sans Pro', sans-serif; 10 | -webkit-font-smoothing: antialiased; 11 | } 12 | 13 | ::selection { 14 | background: #ff0; 15 | } 16 | 17 | .nav { 18 | display: flex; 19 | height: 60px; 20 | width: 100%; 21 | position: fixed; 22 | top: 0; 23 | left: 0; 24 | background: rgba(46,53,53,.95); 25 | align-items: center; 26 | } 27 | 28 | .nav a { 29 | height: 60%; 30 | max-width: 100%; 31 | } 32 | 33 | .nav img { 34 | height: 100%; 35 | margin-left: 20px; 36 | } 37 | 38 | .nav p { 39 | color: rgba(137,161,157,1); 40 | font-size: 1rem; 41 | text-transform: uppercase; 42 | letter-spacing: 2px; 43 | margin: 0; 44 | margin-left: 20px; 45 | padding-left: 20px; 46 | border-left: 1px solid rgba(255,255,255,.1); 47 | } 48 | 49 | #mdForm > * { 50 | box-sizing: border-box; 51 | margin: 0; 52 | } 53 | 54 | #editor .label { 55 | position: fixed; 56 | top: 100px; 57 | left: 60px; 58 | color: #fff; 59 | background: rgba(100,125,125,.35); 60 | height: auto; 61 | width: auto; 62 | padding: 0em .4em; 63 | border-radius: 5px; 64 | } 65 | 66 | #editor .label.preview { 67 | left: 60%; 68 | transform: translate(60px, 0); 69 | } 70 | 71 | 72 | #mdForm { 73 | height: 100%; 74 | width: 60%; 75 | background: #edf0ef; 76 | padding: 160px 60px 0px 60px; 77 | box-sizing: border-box; 78 | display: flex; 79 | flex-direction: column; 80 | } 81 | 82 | #mdForm input.meta { 83 | display: block; 84 | width: 100%; 85 | background: transparent; 86 | border: 0; 87 | font-size: 1.2rem; 88 | font-family: 'Source Code Pro', sans-serif; 89 | border: none; 90 | outline: none; 91 | padding: 20px 0; 92 | border-bottom: 1px dashed #cdd0cf; 93 | } 94 | 95 | #mdForm label { 96 | color: #8d908f; 97 | margin-top: 20px; 98 | } 99 | 100 | #mdForm label:first-of-type { 101 | margin: 0; 102 | } 103 | 104 | textarea.main { 105 | display: block; 106 | font-family: 'Source Code Pro', sans-serif; 107 | padding-top: 20px; 108 | width: 100%; 109 | height: auto; 110 | margin: 0 auto; 111 | -webkit-appearance: none; 112 | resize: none; 113 | border: none; 114 | outline: none; 115 | font-size: 1.2rem; 116 | background: transparent; 117 | flex-grow: 1; 118 | overflow: scroll-y; 119 | } 120 | 121 | textarea::selection, input.meta::selection { 122 | color: #660; 123 | } 124 | 125 | textarea.hidden { 126 | display: none; 127 | } 128 | 129 | #preview { 130 | width: 40%; 131 | height: 100%; 132 | padding: 160px 60px 60px 60px; 133 | overflow-y: scroll; 134 | position: absolute; 135 | top: 0; 136 | right: 0; 137 | } 138 | 139 | button#mdFormButton { 140 | display: block; 141 | position: fixed; 142 | z-index: 2; 143 | font-family: 'Source Sans Pro', sans-serif; 144 | top: 0; 145 | right: 0; 146 | color: #fff; 147 | background: rgba(35,40,40,1); 148 | border: 0; 149 | font-size: 1rem; 150 | text-transform: uppercase; 151 | letter-spacing: 2px; 152 | padding: 20px; 153 | text-align: center; 154 | cursor: pointer; 155 | width: 200px; 156 | box-sizing: border-box; 157 | transition: all 500ms; 158 | } 159 | 160 | button#mdFormButton:hover { 161 | background: rgba(25,30,30,1); 162 | } 163 | 164 | .toolbar { 165 | display: flex; 166 | z-index: 3; 167 | position: fixed; 168 | top: 0; 169 | right: -100%; 170 | width: 100%; 171 | color: #fff; 172 | align-items: center; 173 | justify-content: flex-end; 174 | transition: all 500ms; 175 | } 176 | 177 | .toolbar { 178 | transition: all 500ms; 179 | } 180 | 181 | .toolbar a { 182 | text-decoration: none; 183 | color: #fff; 184 | background: rgba(35,40,40,1); 185 | font-size: 1rem; 186 | text-transform: uppercase; 187 | letter-spacing: 2px; 188 | padding: 20px; 189 | text-align: center; 190 | width: 200px; 191 | box-sizing: border-box; 192 | } 193 | 194 | .toolbar a:hover { 195 | background: rgba(25,30,30,1); 196 | } 197 | 198 | body.submitted button#mdFormButton, body.pdfCreated button#mdFormButton { 199 | right: -100%; 200 | } 201 | 202 | body.submitted .toolbar { 203 | right: 0; 204 | } 205 | 206 | body.submitted .toolbar a { 207 | display: none; 208 | } 209 | 210 | body.submitted .toolbar:after { 211 | display: block; 212 | width: auto; 213 | font-size: 1rem; 214 | font-style: italic; 215 | color: #5dc295; 216 | padding: 20px; 217 | text-align: center; 218 | box-sizing: border-box; 219 | content: 'Fabricating typographic solution...'; 220 | } 221 | 222 | body.pdfCreated .toolbar { 223 | right: 0; 224 | animation-name: transitionIn; 225 | animation-duration: 250ms; 226 | animation-iteration-count: 1; 227 | -webkit-animation-name: transitionIn; 228 | -webkit-animation-duration: 250ms; 229 | -webkit-animation-iteration-count: 1; 230 | } 231 | 232 | body.pdfCreated .toolbar a { 233 | display: block; 234 | } 235 | 236 | @keyframes transitionIn { 237 | from { right: -100%; } 238 | to { right: 0%; } 239 | } 240 | 241 | @-webkit-keyframes transitionIn { 242 | from { right: -100%; } 243 | to { right: 0%; } 244 | } 245 | -------------------------------------------------------------------------------- /lib/assets/logo-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 11 | 12 | 15 | 16 | 21 | 22 | 24 | 50 | 51 | 53 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /lib/assets/markdownPreview.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: 'Source Sans Pro', sans-serif; 3 | color: #4c5859; 4 | font-size: 14px; 5 | } 6 | 7 | #articleContent { 8 | position: relative; 9 | width: 100%; 10 | } 11 | 12 | dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, 13 | form, fieldset, input, p, blockquote, table, th, td, embed, object, hr { 14 | padding: 0; 15 | margin: 0; 16 | } 17 | 18 | a { 19 | color: #4cb5ff; 20 | text-decoration: none; 21 | } 22 | 23 | @media print { 24 | body { 25 | font-size: 10pt; 26 | } 27 | 28 | #cover { 29 | display: block; 30 | width: 100%; 31 | height: 100%; 32 | padding-top: 50%; 33 | box-sizing: border-box; 34 | } 35 | 36 | #cover h1 { 37 | font-size: 500%; 38 | display: block; 39 | width: 100%; 40 | } 41 | 42 | #cover h4 { 43 | width: 100%; 44 | } 45 | 46 | h1, h2, h3, h4, h5, h6, aside, blockquote, pre { 47 | page-break-inside: avoid; 48 | } 49 | 50 | h2 { 51 | page-break-before: always; 52 | } 53 | 54 | h2:first-of-type { 55 | page-break-before: avoid; 56 | } 57 | } 58 | 59 | h1, h2, h3, h4, h5, h6 { 60 | font-family: 'Source Sans Pro', sans-serif; 61 | font-weight: 700; 62 | margin: 0 auto; 63 | margin-bottom: .25rem; 64 | margin-top: 0rem; 65 | line-height: 1.2em; 66 | width: 75%; 67 | } 68 | 69 | h1, h2, h3 { 70 | margin-bottom: 1rem; 71 | } 72 | 73 | h1 { 74 | font-size: 340%; 75 | } 76 | 77 | h2 { 78 | font-size: 230%; 79 | text-decoration: underline; 80 | text-transform: capitalize; 81 | } 82 | 83 | h3 { 84 | font-size: 150%; 85 | } 86 | 87 | h4, h5, h6 { 88 | font-size: 100%; 89 | color: #5bc193; 90 | line-height: 1.5em; 91 | font-weight: normal; 92 | font-style: italic; 93 | } 94 | 95 | p { 96 | width: 75%; 97 | margin: 0 auto; 98 | font-size: 100%; 99 | margin-bottom: 1rem; 100 | line-height: 1.5em; 101 | } 102 | 103 | p:first-child { 104 | margin-top: 0; 105 | } 106 | 107 | hr { 108 | margin: 3rem 0; 109 | border: 0; 110 | border-bottom: 1px solid #c4d0ce; 111 | } 112 | 113 | ul, ol { 114 | margin: 1rem auto; 115 | padding-left: 1rem; 116 | width: 75%; 117 | box-sizing: border-box; 118 | } 119 | 120 | li { 121 | margin-bottom: .5rem; 122 | } 123 | 124 | li p { 125 | margin: 0 auto; 126 | width: 100%; 127 | } 128 | 129 | blockquote { 130 | border-radius: 0; 131 | border-left: 1pt solid #5bc193; 132 | margin: 1.8rem 0; 133 | padding-left: 1.25rem; 134 | } 135 | 136 | blockquote, pre { 137 | display: block; 138 | width: 75%; 139 | box-sizing: border-box; 140 | white-space: normal; 141 | } 142 | 143 | blockquote > *, pre > * { 144 | margin: 0; 145 | padding: 0; 146 | } 147 | 148 | blockquote p { 149 | font-size: 125%; 150 | width: 100%; 151 | font-weight: light; 152 | font-style: italic; 153 | } 154 | 155 | blockquote h4 { 156 | width: 100%; 157 | color: #4c5859; 158 | font-weight: bold; 159 | font-style: normal; 160 | } 161 | 162 | pre { 163 | margin: 0 auto; 164 | border-radius: 5px; 165 | } 166 | 167 | pre code { 168 | border: none; 169 | background: transparent; 170 | } 171 | 172 | img, p img { 173 | max-width: 100%; 174 | height: auto; 175 | } 176 | 177 | pre { 178 | 179 | } 180 | 181 | code{ 182 | background: #f7fcfa; 183 | border: 1px solid #e2eae9; 184 | line-height: 1.5em; 185 | color: #d95136; 186 | padding: 0 3px; 187 | font-family: 'Source Code Pro', monospace; 188 | white-space: pre-wrap; 189 | } 190 | 191 | code.added { 192 | color: green; 193 | margin-bottom: 20px; 194 | display: block; 195 | } 196 | 197 | /*Aside Styles*/ 198 | 199 | 200 | aside { 201 | float: right; 202 | width: 37.5%; 203 | margin: 0 0 0 1.8rem; 204 | } 205 | 206 | aside p { 207 | margin-left: 0; 208 | width: 100%; 209 | font-size: 70%; 210 | margin-bottom: 1em; 211 | } 212 | 213 | aside h1, aside h2, aside h3, aside h4, aside h5, aside h6 { 214 | width: 100%; 215 | color: #4c5859; 216 | font-size: .7rem; 217 | text-transform: uppercase; 218 | letter-spacing: 1px; 219 | font-style: normal; 220 | font-weight: bold; 221 | } 222 | 223 | aside p img, aside img { 224 | max-width: 100%; 225 | height: auto; 226 | } 227 | 228 | 229 | /*Preview Only Styles*/ 230 | 231 | 232 | #preview > *:first-child, body.markdownConverted > *:first-child { 233 | margin-top: 0; 234 | } 235 | 236 | #preview #cover { 237 | padding-bottom: 30px; 238 | border-bottom: 1px solid #c4d0ce; 239 | margin-bottom: 30px; 240 | } 241 | 242 | section:first-of-type{ 243 | margin-top: 90px; 244 | } 245 | 246 | h3.updated{ 247 | background-color: #52AE3C; 248 | color: #fff; 249 | padding: 5px; 250 | text-align: center; 251 | } 252 | 253 | h3.preview{ 254 | background-color: #4CB5ff; 255 | color: #fff; 256 | padding: 5px; 257 | text-align: center; 258 | } 259 | -------------------------------------------------------------------------------- /lib/docs/assert.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/assert.html)] 2 | 3 | - [`assert.deepEqual()`](https://iojs.org/api/assert.html#assert_assert_deepequal_actual_expected_message) no longer checks for `prototype` equality. 4 | - [`assert.deepStrictEqual()`](https://iojs.org/api/assert.html#assert_assert_deepstrictequal_actual_expected_message) was introduced to deal with some former expectations about `deepEqual()` which were not true. 5 | - Refs: [`e7573f9`](https://github.com/nodejs/node/commit/e7573f9111f6b85c599ec225714d76e08ec8a4dc), [`3f473ef`](https://github.com/nodejs/node/commit/3f473ef141fdc7059928ebc4542b00e2f126ab07) 6 | -------------------------------------------------------------------------------- /lib/docs/buffer.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/buffer.html)] 2 | 3 | - External memory is now allocated using [TypedArrays](https://developer.mozilla.org/en/docs/Web/JavaScript/Typed_arrays), instead of using `SlowBuffer` or `smalloc` as the parent backing. 4 | - Refs: [`63da0df`](https://github.com/nodejs/node/commit/63da0dfd3a4460e117240e84b57af2137469497e) 5 | 6 | --- 7 | 8 | - [`Buffer.concat()`](https://iojs.org/api/buffer.html#buffer_class_method_buffer_concat_list_totallength) now always creates a new buffer, even if only called with one element. 9 | - Refs: [`f4f16bf`](https://github.com/nodejs/io.js/commit/f4f16bf03980df4d4366697d40e80da805a38bf8), [#1891](https://github.com/nodejs/io.js/issues/1891), [#1937](https://github.com/nodejs/io.js/pull/1937) 10 | - [`SlowBuffer`](https://iojs.org/api/buffer.html#buffer_class_slowbuffer) has been repurposed to return a `Buffer` instance who's parent backing is not pooled. 11 | - Refs: [`456942a`](https://github.com/nodejs/node/commit/456942a920fe313ebe0b0da366d26ef400ec177e) 12 | - [`Buffer.prototype.toJSON()`](https://iojs.org/api/buffer.html#buffer_buf_tojson)'s output is no longer the same as an array. Instead it is an object specifically tagged as a buffer, which can be recovered by passing it to (a new overload of) the `Buffer` constructor. 13 | - Refs: [`840a29f`](https://github.com/nodejs/node/commit/840a29fc0fd256a63b3f2f5e7528de5107a608a3) 14 | - `Buffer.prototype.parent` is now a getter that points to `buffer.buffer` if the buffer's size is greater than zero. 15 | - Refs: [`63da0df`](https://github.com/nodejs/node/commit/63da0dfd3a4460e117240e84b57af2137469497e) 16 | - `Buffer.prototype.offset` is now a read-only getter that returns `buffer.byteOffset`. 17 | - Refs: [`63da0df`](https://github.com/nodejs/node/commit/63da0dfd3a4460e117240e84b57af2137469497e) 18 | - [`Buffer.prototype.fill()`](https://iojs.org/api/buffer.html#buffer_buf_fill_value_offset_end) now accepts multi-character strings and will fill with the entire passed value. Additionally, `fill()` now returns its `buffer` and can be chained. 19 | - Refs: [`57ed3da`](https://github.com/nodejs/node/commit/57ed3daebfe4700b14cd551f50240f1a634dbd64) 20 | - `Buffer.prototype._charsWritten` no longer is written to, nor exists. 21 | - Refs: [`ccda6bb`](https://github.com/nodejs/node/commit/ccda6bb3ac99ee46508860385128f47a3d5547e5) 22 | 23 | #### Buffer changes from V8 24 | 25 | Implementation changes in V8 have caused subtle impacts how buffers work with encodings in certain cases. 26 | 27 | - `(new Buffer('text\0!', 'ascii')).toString()` outputs `'text !'` in 0.10 and `'text\u0000!'` in 0.12. 28 | - Invalid unicode characters are replaced to no longer become invalid. 29 | - Refs: [#2344](https://github.com/nodejs/node/issues/2344) 30 | -------------------------------------------------------------------------------- /lib/docs/child_process.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/child_process.html)] 2 | 3 | - [`ChildProcess.prototype.send()`](https://iojs.org/api/child_process.html#child_process_child_send_message_sendhandle) is now always asynchronous, where previously it was blocking on Unix. 4 | - Pull request [#2620](https://github.com/nodejs/node/pull/2620), which should land before 4.0.0, will make `send()` accept a callback as the last argument, with will be called with one argument: `null` if it succeeded, or an `Error` if it failed. 5 | - Refs: [#760](https://github.com/nodejs/node/issues/760), [#2620](https://github.com/nodejs/node/pull/2620) 6 | - The `customFds` option for [`ChildProcess.prototype.spawn()`](https://iojs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) is deprecated. Instead of `customFds` you can use the [`stdio`](https://iojs.org/api/child_process.html#child_process_options_stdio) option like [this example](https://github.com/mochajs/mocha/pull/1364/files). 7 | - Refs: [`2454695`](https://github.com/nodejs/node/commit/245469587c7a6326d1b55bdf6c6d6650d72bfa22) 8 | - The [`'disconnect'`](https://iojs.org/api/child_process.html#child_process_event_disconnect) event on a `ChildProcess` is now fired asynchronously. 9 | - Refs: [`b255f4c`](https://github.com/nodejs/node/commit/b255f4c10a80343f9ce1cee56d0288361429e214) 10 | -------------------------------------------------------------------------------- /lib/docs/cluster.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/cluster.html)] 2 | 3 | - Cluster now uses round-robin load balancing by default on non-Windows platforms. The scheduling policy is configurable by setting [`cluster.schedulingPolicy`](https://iojs.org/api/cluster.html#cluster_cluster_schedulingpolicy). 4 | - It is advised that you do not use round-robin balancing on windows as it is very inefficien. 5 | - Refs: [`e72cd41`](https://github.com/nodejs/node/commit/e72cd415adf2ca12daddc001cc3fe953cdb4b507) 6 | - Cluster has been made `--debug`-aware. 7 | - Refs: [`43ec1b1`](https://github.com/nodejs/node/commit/43ec1b1c2e77d21c7571acd39860b9783aaf5175), [`3821863`](https://github.com/nodejs/node/commit/3821863109be9e56f41f1ea6da0cb6e822037fc3), [`11c1bae`](https://github.com/nodejs/node/commit/11c1bae734dae3a017f2c4f3f71b5e679a9ddfa6), [`423d894`](https://github.com/nodejs/node/commit/423d8944ce58bc8c3f90d2827339a4dea10ab96e) 8 | - Cluster's [`'setup'`](https://iojs.org/api/cluster.html#cluster_event_setup) event now fires asynchronously. 9 | - Refs: [`876d3bd`](https://github.com/nodejs/node/commit/876d3bd85aabe7fce71a025a89c6b3f6ddbf2053) 10 | - Open connections (and other handles) in the master process are now closed when the last worker that holds a reference to them quits. Previously, they were only closed at cluster shutdown. 11 | - A side-effect of this is that the cluster master will refuse connections if there are no workers. 12 | - Refs: [`41b75ca`](https://github.com/nodejs/node/commit/41b75ca9263f368db790fbdcc3963bb1a8c5cb7e), [#2606](https://github.com/nodejs/node/pull/2606), [#1239](https://github.com/nodejs/node/issues/1239) 13 | -------------------------------------------------------------------------------- /lib/docs/crypto.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/crypto.html)] 2 | 3 | - [`crypto.randomBytes()`](https://iojs.org/api/crypto.html#crypto_crypto_randombytes_size_callback) now blocks if there is insufficient entropy. 4 | - Although it blocks, it should normally never take longer than a few milliseconds. 5 | - `crypto.pseudoRandomBytes()` is now an alias to `crypto.randomBytes()`. 6 | - Refs: [`e5e5980`](https://github.com/nodejs/node/commit/e5e598060eb43faf2142184d523a04f0ca2d95c3) 7 | - [`crypto.Sign.prototype.sign()`](https://iojs.org/api/crypto.html#crypto_sign_sign_private_key_output_format) will no longer swallow internal OpenSSL errors. 8 | - Refs: [`00bffa6`](https://github.com/nodejs/node/commit/00bffa6c758038dca039fd9114912c0430114c08) 9 | -------------------------------------------------------------------------------- /lib/docs/dgram.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/dgram.html)] 2 | 3 | - [`dgram.Socket.prototype.send()`](https://iojs.org/api/dgram.html#dgram_socket_send_buf_offset_length_port_address_callback) error semantics have changed. 4 | - Through 2.x, the the dgram `socket.send()` method emitted errors when a DNS lookup failed, even when a callback was provided. Starting from 3.0.0, if a callback is provided, no error event will be emitted. 5 | - When `send()` is supplied with a callback, it will no longer emit the `'error'` event when an error occurs and instead pass the error to the callback. 6 | - Previously the behavior was to do _both_. 7 | - Refs: [#1796](https://github.com/nodejs/io.js/pull/1796) 8 | -------------------------------------------------------------------------------- /lib/docs/domain.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/domain.html)] 2 | 3 | The domain module [has been scheduled for deprecation](https://iojs.org/api/domain.html#domain_domain), awaiting an alternative for those who absolutely **need** domains. 4 | 5 | It is suggested you avoid using domains if possible and rather rely on regular error checking. 6 | 7 | - [`domain.dispose()`](https://iojs.org/api/domain.html#domain_domain_dispose) has been deprecated. 8 | - Please recover from failed IO actions explicitly via error event handlers set on the domain. 9 | - Refs: [`d86814a`](https://github.com/nodejs/node/commit/d86814aeca64d8985402dc073eff1fc8ac93c231) 10 | -------------------------------------------------------------------------------- /lib/docs/events.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/events.html)] 2 | 3 | - [`EventEmitter.listenerCount()`](https://iojs.org/api/events.html#events_class_method_eventemitter_listenercount_emitter_event) is now deprecated in favour of `EventEmitter.prototype.listenerCount()`. 4 | - Refs: [`8f58fb9`](https://github.com/nodejs/node/commit/8f58fb92fff904a6ca58fd0df9ee5a1816e5b84e) 5 | -------------------------------------------------------------------------------- /lib/docs/freelist.md: -------------------------------------------------------------------------------- 1 | - The `freelist` module was only ever intended for internal use and is now deprecated. 2 | - Refs: [`fef87fe`](https://github.com/nodejs/node/commit/fef87fee1de60c3d5db2652ee2004a6e78d112ff), [#569](https://github.com/nodejs/node/issues/569) 3 | -------------------------------------------------------------------------------- /lib/docs/fs.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/fs.html)] 2 | 3 | - [`fs.createReadStream()`](https://iojs.org/api/fs.html#fs_fs_createreadstream_path_options) and [`fs.createWriteStream()`](https://iojs.org/api/fs.html#fs_fs_createwritestream_path_options) now have stricter type-checking for the `options` argument. 4 | - Refs: [`353e26e`](https://github.com/nodejs/node/commit/353e26e3c7) 5 | - [`fs.exists()`](https://iojs.org/api/fs.html#fs_fs_exists_path_callback) is now deprecated. It is suggested to use either [`fs.access()`](https://iojs.org/api/fs.html#fs_fs_access_path_mode_callback) or [`fs.stat()`](https://iojs.org/api/fs.html#fs_fs_stat_path_callback). Please read the documentation carefully. 6 | - Added more informative errors and method call site details when the `NODE_DEBUG` environment is set to ease debugging. 7 | - The same thing applies to the synchronous versions of these APIs. 8 | - Refs: [`1f76a2e`](https://github.com/nodejs/node/commit/1f76a2eddc3561ff2c434d491e0d2b893c374cfd) 9 | - Fixed missing callbacks errors just being printed instead of thrown. 10 | - Refs: Probably [`1f40b2a`](https://github.com/nodejs/node/commit/1f40b2a63616efe0e4c0744a1f630161526e4236) 11 | - On Unix soft `ulimit` values are ignored. 12 | - Refs: [`6820054`](https://github.com/nodejs/node/commit/6820054d2d42ff9274ea0755bea59cfc4f26f353), [joyent/node#8704](https://github.com/joyent/node/issues/8704) 13 | - Errors for async `fs` operations are now thrown if a callback is not present. 14 | - Refs: [`a804347`](https://github.com/nodejs/node/commit/a80434736bce22a9ac00376bb5786806752ef3dd), [`6bd8b7e`](https://github.com/nodejs/node/commit/6bd8b7e5405e1cdc9f56214f5f6b741806c32e5f), [`5e140b3`](https://github.com/nodejs/node/commit/5e140b33e58bd0ac6779fb0cb635dd51e1a27289) 15 | - The error messages of most `fs` errors have been improved to be more descriptive and useful. 16 | - Refs: [`bc2c85c`](https://github.com/nodejs/node/commit/bc2c85ceef7ac034830e4a4357d0aef69cd6e386) 17 | 18 | -------------------------------------------------------------------------------- /lib/docs/http.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/http.html)] 2 | 3 | - http server timing change (Use `'finish'` instead of `'prefinish'` when ending a response) 4 | - When doing HTTP pipelining of requests, the server creates new request and response objects for each incoming HTTP request on the socket. Starting from 3.0.0, these objects are now created a couple of ticks later, when we are certainly done processing the previous request. This could change the observable timing with certain HTTP server coding patterns. 5 | - The switch to `'finish'` is intended to prevent the socket being detached from the response until after the data is actually sent to the other side. 6 | - Refs: [`6020d2`](https://github.com/nodejs/io.js/commit/6020d2a2fb75de6766c807864fa8f1c0fba88ec9), [#1411](https://github.com/nodejs/io.js/pull/1411) 7 | - Removed default chunked encoding on `DELETE` and `OPTIONS` requests. 8 | - Refs: [`aef0960`](https://github.com/nodejs/node/commit/aef09601b4320648f4b6fac0baba3e5c54b0406a), [`1df32af`](https://github.com/nodejs/node/commit/1df32af74a450d456e264afbbaf6201a388d7572) 9 | - [`http.STATUS_CODES`](https://iojs.org/api/http.html#http_http_status_codes) now maps to the regulated [IANA standard](http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) set of codes. 10 | - Updating the code mappings to conform to the IANA standard was a backwards incompatible change to consumers who depend on the text value of a header. The most significant of these changes was the text for `302`, which was previously `Moved Temporarily` but is now `Found`. 11 | - Refs: [`235036e`](https://github.com/nodejs/io.js/commit/235036e7faa537469c3600850bdd533c095c392a), [#1470](https://github.com/nodejs/io.js/pull/1470) 12 | - [`http.Agent.prototype.getName()`](https://iojs.org/api/http.html#http_agent_getname_options) no longer returns an extra trailing colon. 13 | - Refs: [`06cc919`](https://github.com/nodejs/io.js/commit/06cc919a0cd41380a83e4ea699f1a9ea30881266), [#1617](https://github.com/nodejs/io.js/pull/1617) 14 | - `http.OutgoingMessage.prototype.flush()` has been deprecated in favor of the new [`flushHeaders()`](https://iojs.org/api/http.html#http_request_flushheaders) method. The behavior remains the same. 15 | - Note: these methods reside on **both** the common http `request` and `response` objects. 16 | - Refs: [`b2e00e3`](https://github.com/nodejs/node/commit/b2e00e38dcac23cf564636e8fad880829489286c), [`joyent/node@89f3c90`](https://github.com/joyent/node/commit/89f3c9037faf19eb32c464b2e02a0a9191156c36) 17 | - [`http.OutgoingMessage.prototype.write()`](https://iojs.org/api/http.html#http_response_write_chunk_encoding_callback) will now emit an error on the `OutgoingMessage` (`response`) object if it has been called after [`end()`](https://iojs.org/api/http.html#http_response_end_data_encoding_callback). 18 | - Refs: [`64d6de9`](https://github.com/nodejs/node/commit/64d6de9f34abe63bf7602ab0b55ff268cf480e45) 19 | - [`http.request()`](https://iojs.org/api/http.html#http_http_request_options_callback) and [`http.get()`](https://iojs.org/api/http.html#http_http_get_options_callback) wrongly decode multi-byte string characters as `'binary'`. 20 | - Notes: This bug still exists in 4.0.0. 21 | - Refs: [#2114](https://github.com/nodejs/node/issues/2114), [joyent/node#25634 (comment)](https://github.com/joyent/node/issues/25634#issuecomment-118970793) 22 | - [`http.request()`](https://iojs.org/api/http.html#http_http_request_options_callback) and [`http.get()`](https://iojs.org/api/http.html#http_http_get_options_callback) now throw a TypeError if the requested path contains illegal characters. (Currently only `' '`). 23 | - Refs: [`7124387`](https://github.com/nodejs/node/commit/7124387b3414c41533078f14a84446e2e0a6ff95) 24 | -------------------------------------------------------------------------------- /lib/docs/net.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/net.html)] 2 | 3 | - [`net.Server.prototype.address()`]() now also returns a `{ address: '/path/to/socket' }` object, like it does for TCP and UDP sockets. 4 | - Previously it returned `socket._pipeName` directly for unix sockets. 5 | - Refs: [`f337595`](https://github.com/nodejs/node/commit/f337595441641ad36f6ab8ae770e56c1673ef692) 6 | - [`net.Server.prototype.listen()`](https://iojs.org/api/net.html#net_server_listen_port_hostname_backlog_callback) will now try to bind to `::` (IPv6) if the bind address is omitted, and use `0.0.0.0` (IPv4) as a fallback. 7 | - Refs: [`2272052`](https://github.com/nodejs/node/commit/2272052461445dfcae729cc6420a3d3229362158) 8 | -------------------------------------------------------------------------------- /lib/docs/os.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/os.html)] 2 | 3 | - [`os.tmpdir()`](https://iojs.org/api/os.html#os_os_tmpdir) now never returns a trailing slash regardless of the host platform. 4 | - Refs: [`bb97b70`](https://github.com/iojs/io.js/commit/bb97b70eb709b0e0470a5164b3722c292859618a), [#747](https://github.com/iojs/io.js/pull/747) 5 | - `os.tmpdir()` on Windows now uses the `%SystemRoot%` or `%WINDIR%` environment variables instead of the hard-coded value of `c:\windows` when determining the temporary directory location. 6 | - Refs: [`120e5a2`](https://github.com/nodejs/node/commit/120e5a24df76deb5019abec9744ace94f0f3746a) 7 | -------------------------------------------------------------------------------- /lib/docs/path.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/path.html)] 2 | 3 | - [`path.isAbsolute()`](https://iojs.org/api/path.html#path_path_isabsolute_path) will now always return a boolean, even on windows. 4 | - Refs: [`20229d6`](https://github.com/nodejs/node/commit/20229d6896ce4b802a0789b1d2643dcac55bebb9) 5 | - Many `path` functions now assert that any paths provided are strings. 6 | - Refs: [`eb995d6`](https://github.com/nodejs/node/commit/eb995d682201018b2a47c44e921848cfa31486a2), [`8de78e4`](https://github.com/nodejs/node/commit/8de78e470d2e291454e2184d7f206c70d4cb8c97) 7 | -------------------------------------------------------------------------------- /lib/docs/process.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/process.html)] 2 | 3 | - Added the concept of `beforeExit` time. 4 | - Before the process emits [`'exit'`](https://iojs.org/api/process.html#process_event_exit) and begins shutting down, it will emit a [`'beforeExit'`](https://iojs.org/api/process.html#process_event_beforeexit) event. Code that is run in the `'beforeExit'` event can schedule async operations that will hold the event loop open, unlike `'exit'` where it is too late to async operations. 5 | - Refs: [`a2eeb43`](https://github.com/nodejs/node/commit/a2eeb43deda58e7bbb8fcf24b934157992b937c0) 6 | - Chunked writes to sdtout/stderr will now be lost if the process is terminated early. 7 | - Chunked writes happen when the string to be written is beyond a certain, fairly large, size. 8 | - Refs: [#784](https://github.com/nodejs/node/issues/784), [#1771](https://github.com/nodejs/node/pull/1771) 9 | - [`process.kill()`](https://iojs.org/api/process.html#process_process_kill_pid_signal) now throws errors on non-numeric input. 10 | - Strings that can be coerced to numbers still work. e.g. `process.kill('0')`. 11 | - Refs: [`832ec1c`](https://github.com/nodejs/node/commit/832ec1cd507ed344badd2ed97d3da92975650a95), [`743a009`](https://github.com/nodejs/node/commit/743a009bad64c4302a724f70c42d73601a16aed4) 12 | - `process.maxTickDepth` has been removed, allowing [`process.nextTick()`](https://iojs.org/api/process.html#process_process_nexttick_callback_arg) to starve I/O indefinitely. 13 | - This is due to adding [`setImmediate()`](https://iojs.org/api/timers.html#timers_setimmediate_callback_arg) in 0.10. 14 | - It is suggested you use `setImmediate()` over `process.NextTick()`. `setImmediate()` likely does what you are hoping for (a more efficient `setTimeout(..., 0)`), and runs after this tick's I/O. `process.nextTick()` does not actually run in the "next" tick anymore and will block I/O as if it were a synchronous operation. 15 | - Refs: [`0761c90`](https://github.com/nodejs/node/commit/0761c90204d7a0134c657e20f91bd83bfa6e677a), [`9a6c085`](https://github.com/nodejs/node/commit/9a6c0853bc164ad2d76f51cdcb0771e881cd0a5f) 16 | - [`process.send()`](https://github.com/nodejs/node/pull/1978) is now always asynchronous, where previously it was blocking on Unix. 17 | - Pull request [#2620](https://github.com/nodejs/node/pull/2620), which should land before 4.0.0, will make `send()` accept a callback as the last argument, with will be called with one argument: `null` if it succeeded, or an `Error` if it failed. 18 | - Refs: [#760](https://github.com/nodejs/node/issues/760), [#2620](https://github.com/nodejs/node/pull/2620) 19 | 20 | #### Signal handling 21 | 22 | In node 0.10.x, exit from a fatal signal was accomplished by a signal handler in 23 | node which called `exit(128 + signo)`. So for `SIGINT` (signal 2), a node process 24 | observing the exit of a spawned node process would observe that process exiting 130, 25 | but no signal would be noted (see [`waitid(2)`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitid.html) for more information on how a process 26 | waiting for another determines if the waitee exited due to a signal). In node 27 | 0.12.x, a node process observing the exit of a spawned child node process will 28 | see a null `code`, and a `'SIGINT'` as the signal. 29 | 30 | Here is a pair of test programs which illustrates the difference. 31 | 32 | $ cat sleeper.js 33 | setTimeout(function () {}, 300000) 34 | 35 | $ cat test.js 36 | var cp = require("child_process") 37 | var p = cp.spawn("node", ["sleeper.js"]) 38 | p.on('exit', function (code, signal) { 39 | console.log("code=" + code + ", signal=" + signal) 40 | }) 41 | setTimeout(function () { p.kill('SIGINT') }, 2000) 42 | 43 | 44 | On node 0.10 this produces: 45 | 46 | $ node test.js 47 | code=130, signal=null 48 | 49 | On node 0.12+ this produces: 50 | 51 | $ node test.js 52 | code=null, signal=SIGINT 53 | 54 | This can be a subtle porting issue for multi-process node environments which care 55 | about signals (such as test harnesses). This change was introduced by 56 | [`c61b0e9`—`main: Handle SIGINT properly`](https://github.com/joyent/node/commit/c61b0e9cbc748c5e90fc5e25e4fb490b4104cae3). 57 | -------------------------------------------------------------------------------- /lib/docs/querystring.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/querystring.html)] 2 | 3 | - querystring's `stringifyPrimitive()` now stringifies numbers correctly. 4 | - Refs: [`c9aec2b`](https://github.com/nodejs/node/commit/c9aec2b7167a08dc88141fbe3be1c498f8c5b061) 5 | - [`querystring.stringify()`](https://iojs.org/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options) no longer accepts a 4th, undocumented, `name` parameter. 6 | - Refs: [`8d3bc88`](https://github.com/nodejs/node/commit/8d3bc88bbe3c0690f433a97c1df33fca099f18be) 7 | 8 | -------------------------------------------------------------------------------- /lib/docs/smalloc.md: -------------------------------------------------------------------------------- 1 | `smalloc` was a core module in 0.12 and io.js <3.0.0 for doing (external) raw memory allocation/deallocation/copying in JavaScript. 2 | 3 | `smalloc` was removed in io.js 3.0.0, as the required v8 APIs were removed. `smalloc` used to be used in the buffer implementation, however buffers are now built ontop of TypedArrays (Specifically Uint8Array). 4 | -------------------------------------------------------------------------------- /lib/docs/stream.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/stream.html)] 2 | 3 | The changes to streams are not as drastic as the transition from streams1 to streams2: they are a 4 | refinement of existing ideas, and should make the API slightly less surprising for humans and faster 5 | for computers. As a whole the changes are referred to as "streams3", but the changes should largely go 6 | unnoticed by the majority of stream consumers and implementers. 7 | 8 | #### Readable Streams 9 | 10 | The distinction between "flowing" and "non-flowing" modes has been refined. Entering "flowing" mode is 11 | no longer an irreversible operation—it is possible to return to "non-flowing" mode from "flowing" mode. 12 | Additionally, the two modes now flow through the same machinery instead of replacing methods. Any time 13 | data is returned as a result of a [`.read()`](https://iojs.org/api/stream.html#stream_readable_read_size) call that data will *also* be emitted on the [`'data'`](https://iojs.org/api/stream.html#stream_event_data) event. 14 | 15 | As before, adding a listener for the [`'readable'`](https://iojs.org/api/stream.html#stream_event_readable) or `'data'` event will start flowing the stream; as 16 | will piping to another stream. 17 | 18 | #### Writable Streams 19 | 20 | The ability to "bulk write" to underlying resources has been added to `Writable` streams. For stream 21 | implementers, one can signal that a stream is bulk-writable by specifying a [_writev](https://iojs.org/api/stream.html#stream_writable_writev_chunks_callback) method. 22 | Bulk writes will occur in two situations: 23 | 24 | 1. When a bulk-writable stream is clearing its backlog of buffered write requests, 25 | 2. or if an end user has made use of the new [`.cork()`](https://iojs.org/api/stream.html#stream_writable_cork) and [`.uncork()`](https://iojs.org/api/stream.html#stream_writable_uncork) API methods. 26 | 27 | `.cork` and `.uncork` allow the end user to control the buffering behavior of writable streams separate 28 | from exerting backpressure. `.cork()` indicates that the stream should accept new writes (up to `.highWaterMark`), 29 | while `.uncork()` resets that behavior and attempts to bulk-write all buffered writes to the underlying resource. 30 | 31 | The only core stream API that **currently** implements `_writev()` is [`net.Socket`](https://iojs.org/api/net.html#net_class_net_socket). 32 | 33 | In addition to the bulk-write changes, the performance of repeated small writes to non-bulk-writable streams 34 | (such as `fs.WriteStream`) has been drastically improved. Users piping high volume log streams to disk should 35 | see an improvement. 36 | 37 | For a detailed overview of how streams3 interact, [see this diagram](https://cloud.githubusercontent.com/assets/37303/5728694/f9a3e300-9b20-11e4-9e14-a6938b3327f0.png). 38 | 39 | - [`WritableState.prototype.buffer`](https://iojs.org/api/stream.html#stream_buffering) has been deprecated in favor of `_writableState.getBuffer()`, which builds an array from an internal object single-way linked list. 40 | - Mutating the array returned will have no effect as `getBuffer()` constructs it from the linked list. However modifying one of the array's element's `.next` property will effect the list. 41 | - Refs: [`9158666`](https://github.com/nodejs/node/commit/91586661c983f45d650644451df73c8649a8d459) 42 | - `WritableStream.prototype._write()` now gets called with `'buffer'` encoding when chunk is a `Buffer`. 43 | - Refs: [joyent/node#6119](https://github.com/joyent/node/issues/6119) 44 | - Writable streams now emit `'finish'` on the next tick if there was a `write()` when finishing. 45 | - Refs: [joyent/node#6118](https://github.com/joyent/node/issues/6118) 46 | 47 | #### Transform Streams 48 | 49 | - When in `objectMode`, `Transform.prototype._read()` now processes false-y (but not `null`) values, such as `''`, `0`, etc. 50 | - Refs: [`26ca7d7`](https://github.com/nodejs/node/commit/26ca7d73ca9c45112f33579aa5a1293059010779) 51 | -------------------------------------------------------------------------------- /lib/docs/sys.md: -------------------------------------------------------------------------------- 1 | As of 1.0.0 the `sys` module is deprecated. It is advised to use the [`util`](https://iojs.org/api/util.html) module instead. 2 | -------------------------------------------------------------------------------- /lib/docs/timers.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/timers.html)] 2 | 3 | - Updated [`setImmediate()`](https://iojs.org/api/timers.html#timers_setimmediate_callback_arg) to process the full queue each turn of the event loop, instead of one per queue. 4 | - It is suggested you use `setImmediate()` over `process.NextTick()`. `setImmediate()` likely does what you are hoping for (a more efficient `setTimeout(..., 0)`), and runs after this tick's I/O. `process.nextTick()` does not actually run in the "next" tick anymore and will block I/O as if it were a synchronous operation. 5 | - Refs: [`fa46483`](https://github.com/nodejs/node/commit/fa46483fe203f56dccd6e122573857cc2c322220) 6 | - `setImmediate()`'s timing was adjusted slightly, but is still after `process.nextTick()` and I/O, but before regular timeouts and intervals. 7 | - Refs: [`cd37251`](https://github.com/nodejs/node/commit/cd372510bb504b6d3414b01cc8c9ee457b2e16c4) 8 | - Internal timeouts now run in a separate queue with slightly different semantics, and will never keep the process alive on their own. 9 | - This may effect your performance profile. 10 | - It is strongly advised you do not attempt to use `_unrefActive()` as it will probably be hidden in the future. 11 | - Refs: [`f46ad01`](https://github.com/nodejs/node/commit/f46ad012bc5a40194242ea1e9669c9cc25bd7047) 12 | - Timer globals (i.e. `setTimeout()`) are no longer lazy-loaded. 13 | - Refs: [`2903410`](https://github.com/nodejs/node/commit/2903410aa8) 14 | -------------------------------------------------------------------------------- /lib/docs/tls.md: -------------------------------------------------------------------------------- 1 | [[Doc](https://iojs.org/api/tls.html)] 2 | 3 | - The [tls server option `SNICallback`](https://iojs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener) required returning a `secureContext` synchronously as `function (hostname) { return secureContext; }`. The function signature is now asyncronous as `function (hostname, cb) { cb(null, secureContext); }`. You can feature detect with `'function' === typeof cb`. 4 | - Refs: [`048e0e7`](https://github.com/nodejs/node/commit/048e0e77e0c341407ecea364cbe26c8f77be48b8) 5 | - The [tls server option `dhparam`](https://iojs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener) must now have a key length greater than 1024 bits, or else it will throw an error. 6 | - This is effectively a security fix. Please see https://weakdh.org/ for more information. 7 | - Refs: [`9b35be5`](https://github.com/nodejs/node/commit/9b35be5810) 8 | - RC4 is now disabled on the cipher list. 9 | - RC4 is now considered insecure and has been removed from the list of default ciphers for TLS servers. Use the `ciphers` option when starting a new TLS server to supply an alternative list. 10 | - Refs: [#826](https://github.com/nodejs/io.js/pull/826) 11 | - Potentially mitigated if [archive#39](https://github.com/nodejs/node-convergence-archive/issues/39) is merged. 12 | - Implemented TLS streams in C++, boosting their performance. 13 | - Refs: [`1738c77`](https://github.com/nodejs/node/commit/1738c7783526868d86cb213414cb4d40c5a89662) 14 | - Moved & renamed `crypto.createCredentials()` to [`tls.createSecureContext()`](https://iojs.org/api/tls.html#tls_tls_createsecurecontext_details). 15 | - Refs: [`5d2aef1`](https://github.com/nodejs/node/commit/5d2aef17ee56fbbf415ca1e3034cdb02cd97117c) 16 | - Removed SSLv2 and SSLv3 support. 17 | - Both SSLv2 and SSLv3 are now considered too insecure for general use and have been disabled at compile-time. 18 | - Refs: [#290](https://github.com/nodejs/node/pull/290), [#315](https://github.com/nodejs/node/pull/315), [archive#20](https://github.com/nodejs/node-convergence-archive/issues/20) 19 | -------------------------------------------------------------------------------- /lib/docs/url.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/url.html)] 2 | 3 | - [`url.parse()`](https://iojs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost) will now always return a query object and search string, even if they are empty, when `parseQueryString` (the second argument) is set to `true`. 4 | - e.g. a `url.parse(..., true)` return value will now include `{ search: '', query: {} }` where previously both properties would not exist. 5 | - Refs: [`b705b73`](https://github.com/nodejs/node/commit/b705b73e46193c7691be40b732330a49affacedb) 6 | - `url.parse()` now escapes the following characters and spaces (`' '`) in the parsed object's properties: 7 | ``` 8 | < > " ` \r \n \t { } | \ ^ ' 9 | ``` 10 | - e.g. 11 | ``` 12 | url.parse("http://example.com/{z}/{x}/{y}.png#foo{}").href === 'http://example.com/%7Bz%7D/%7Bx%7D/%7By%7D.png#foo%7B%7D' 13 | ``` 14 | - Refs: [#2605](https://github.com/nodejs/node/pull/2605), [#2113](https://github.com/nodejs/node/issues/2113) 15 | - [`url.resolve()`](https://iojs.org/api/url.html#url_url_resolve_from_to) now resolves properly to `'.'` and `'..'`. 16 | - This means that `resolve('/a/b/', '.')` will return `'/a/b/'`, and `resolve('/a/b', '.')` will return `'/a/'`. 17 | - `resolve('/a/b/', '..')` returns `'/a/'`. 18 | - This change, while technically a potentially breaking change, also landed in node 0.10.37. 19 | - Refs: [`faa687b`](https://github.com/nodejs/node/commit/faa687b4be2cea71c545cc1bec631c164b608acd), [#278](https://github.com/nodejs/io.js/pull/278) 20 | -------------------------------------------------------------------------------- /lib/docs/util.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/util.html)] 2 | 3 | - `util.is*()` (`isArray()` ... `isUndefined()`) type-checking functions were added in 0.12 but are scheduled for deprecation. Please use user-land solutions instead. 4 | - The type checking these use will be come brittle with the eventual addition of `Symbol.toStringTag`. 5 | - Refs: [#2447](https://github.com/nodejs/node/pull/2447) 6 | - Updated [`util.format()`](https://iojs.org/api/util.html#util_util_format_format) to receive several changes: 7 | - `-0` is now displayed as such, instead of as `0`. 8 | - Refs: [`b3e4fc6`](https://github.com/nodejs/node/commit/b3e4fc6a48b97b52bd19de43c76b7082dcab4988) 9 | - Anything that is `instanceof Error` is now formatted as an error. 10 | - Refs: [`684dd28`](https://github.com/nodejs/node/commit/684dd28a6c684532336777348875ac11305727b9) 11 | - Circular references in JavaScript objects are now handled for the `%j` specifier. 12 | - Refs: [`2cd7adc`](https://github.com/nodejs/node/commit/2cd7adc7f44e4dfe440162a31a168e6aa9a8cea1) 13 | - Custom `inspect` functions now receive any arguments passed to `util.inspect`. 14 | - Refs: [`07774e6`](https://github.com/nodejs/node/commit/07774e6b9570f90166a54fa87af74b8a7cf9926a) 15 | - Displays the constructor name if available. 16 | - Refs: [`7d14dd9`](https://github.com/nodejs/node/commit/7d14dd9b5e78faabb95d454a79faa513d0bbc2a5) 17 | - The following utilities were deprecated in [`896b2aa`](https://github.com/nodejs/node/commit/896b2aa7074fc886efd7dd0a397d694763cac7ce): 18 | - `util.p()`, `util.debug()`, `util.error()` — Use [`console.error()`](https://iojs.org/api/console.html#console_console_error_data) instead. 19 | - `util.print()`, `util.puts()` — Use [`console.log()`](https://iojs.org/api/console.html#console_console_log_data) instead. 20 | - `util.exec()` — Now found at [`child_process.exec()`](https://iojs.org/api/child_process.html#child_process_child_process_exec_command_options_callback). 21 | - `util.pump()` — Use [`ReadableStream.prototype.pipe()`](https://iojs.org/api/stream.html#stream_readable_pipe_destination_options) instead. 22 | -------------------------------------------------------------------------------- /lib/docs/vm.md: -------------------------------------------------------------------------------- 1 | [[Docs](https://iojs.org/api/vm.html)] 2 | 3 | - The `vm` module has been rewritten to work better, based on the excellent [Contextify](https://github.com/brianmcd/contextify) native module. All of the functionality of Contextify is now in core, with improvements! 4 | - Refs: [`7afdba6`](https://github.com/nodejs/node/commit/7afdba6e0bc3b69c2bf5fdbd59f938ac8f7a64c5) 5 | - Updated [`vm.createContext(sandbox)`](https://iojs.org/api/vm.html#vm_vm_createcontext_sandbox) to "contextify" the sandbox, making it suitable for use as a global for `vm` scripts, and then return it. It no longer creates a separate context object. 6 | - Refs: [`7afdba6`](https://github.com/nodejs/node/commit/7afdba6e0bc3b69c2bf5fdbd59f938ac8f7a64c5) 7 | - Updated most `vm` and `vm.Script` methods to accept an `options` object, allowing you to configure a timeout for the script, the error display behavior, and sometimes the filename (for stack traces). 8 | - Refs: [`fd36576`](https://github.com/nodejs/node/commit/fd3657610e49005dfc778c3f060dbba0a34f286a) 9 | - Updated the supplied sandbox object to be used directly as the global, remove error-prone copying of properties back and forth between the supplied sandbox object and the global that appears inside the scripts run by the `vm` module. 10 | - Refs: [`7afdba6`](https://github.com/nodejs/node/commit/7afdba6e0bc3b69c2bf5fdbd59f938ac8f7a64c5) 11 | 12 | For more information, see the `vm` documentation linked above. 13 | -------------------------------------------------------------------------------- /lib/replacements.js: -------------------------------------------------------------------------------- 1 | var replacements = [ 2 | {search: 'NanAsyncWorker', replace: 'Nan::AsyncWorker'}, 3 | {search: 'NanAsyncQueueWorker', replace: 'Nan::AsyncQueueWorker'}, 4 | {search: 'NanCallback', replace: 'Nan::Callback'}, 5 | {search: 'NanSetInternalFieldPointer', replace: 'Nan::SetInternalFieldPointer'}, 6 | {search: 'NanGetInternalFieldPointer', replace: 'Nan::GetInternalFieldPointer'}, 7 | {search: 'NanNewBufferHandle\\(([^;]+);', replace: 'Nan::NewBuffer($1.ToLocalChecked();'}, 8 | {search: '(NanNew(<(v8::)?String>)?\\([^\\)]*\\))', replace: '$1.ToLocalChecked()'}, 9 | {search: 'NanNew', replace: 'Nan::New'}, 10 | {search: 'NODE_SET_PROTOTYPE_METHOD', replace: 'Nan::SetPrototypeMethod'}, 11 | {search: 'NODE_SET_METHOD', replace: 'Nan::SetMethod'}, 12 | {search: '_NAN_METHOD_ARGS_TYPE', replace: 'Nan::NAN_METHOD_ARGS_TYPE'}, 13 | {search: '(\\W)?args(\\W|\\.|\\[)', replace: '$1info$2'}, 14 | {search: '(^|\\s)(v8::)?Persistent', replace: '$1Nan::Persistent'}, 15 | {search: 'NanAssignPersistent(<\w+>)?\\(([^,]+),\\s*([^)]+)\\)', replace: '$2.Reset($3)'}, 16 | {search: 'NanDisposePersistent\\(([^\\)]+)\\)', replace: '$1.Reset()'}, 17 | {search: 'NanReturnValue', replace: 'info.GetReturnValue().Set'}, 18 | {search: 'NanReturnNull\\(\\)', replace: 'info.GetReturnValue().Set(Nan::Null())'}, 19 | {search: 'NanScope\\(\\)', replace: 'Nan::HandleScope\ scope'}, 20 | {search: 'NanEscapableScope\\(\\)', replace: 'Nan::EscapableHandleScope scope'}, 21 | {search: 'NanEscapeScope', replace: 'scope.Escape'}, 22 | {search: 'NanReturnUndefined\\(\\);', replace: 'return;'}, 23 | {search: 'NanUtf8String', replace: 'Nan::Utf8String'}, 24 | {search: 'NanAsciiString', replace: 'Nan::Utf8String'}, 25 | {search: 'NanObjectWrapHandle\\(([^\\)]+)\\)', replace: '$1->handle()'}, 26 | {search: '(node::)?ObjectWrap', replace: 'Nan::ObjectWrap'}, 27 | {search: 'NanMakeCallback', replace: 'Nan::MakeCallback'}, 28 | {search: 'NanNull', replace: 'Nan::Null'}, 29 | {search: 'NanUndefined', replace: 'Nan::Undefined'}, 30 | {search: 'NanFalse', replace: 'Nan::False'}, 31 | {search: 'NanTrue', replace: 'Nan::True'}, 32 | {search: 'NanThrow(\w+)?Error', replace: 'Nan::Throw$1Error'}, 33 | {search: 'NanThrowTypeError', replace: 'Nan::ThrowTypeError'}, 34 | {search: 'NanError', replace: 'Nan::Error'}, 35 | {search: 'NanGetCurrentContext', replace: 'Nan::GetCurrentContext'}, 36 | {search: '([a-zA-Z0-9_]+)->SetAccessor\\(', replace: 'Nan::SetAccessor($1, '}, 37 | {search: 'NanAdjustExternalMemory', replace: 'Nan::AdjustExternalMemory'}, 38 | {search: 'NanSetTemplate', replace: 'Nan::SetTemplate'}, 39 | {search: 'NanHasInstance\\(([^,]+),\\s*([^)]+)\\)', replace: 'Nan::New($1)->HasInstance($2)'}, 40 | {search: '([a-zA-Z0-9_]+)->ForceSet\\(', replace: 'Nan::ForceSet($1, '} 41 | ] 42 | 43 | module.exports = function () { 44 | return replacements 45 | } 46 | -------------------------------------------------------------------------------- /lib/suggestions.js: -------------------------------------------------------------------------------- 1 | var suggestions = [ 2 | {subsystem: 'assert'}, 3 | {subsystem: 'buffer', exp: 'Buffer'}, 4 | {subsystem: 'child_process'}, 5 | {subsystem: 'cluster'}, 6 | {subsystem: 'crypto'}, 7 | {subsystem: 'dgram'}, 8 | {subsystem: 'domain'}, 9 | {subsystem: 'events'}, 10 | {subsystem: 'freelist'}, 11 | {subsystem: 'fs'}, 12 | {subsystem: 'http'}, 13 | {subsystem: 'net'}, 14 | {subsystem: 'os'}, 15 | {subsystem: 'path'}, 16 | {subsystem: 'process', exp: 'process\.'}, 17 | {subsystem: 'querystring', exp: 'querystring\.'}, 18 | {subsystem: 'smalloc', exp: 'smalloc\.'}, 19 | {subsystem: 'stream'}, 20 | {subsystem: 'string_decoder'}, 21 | {subsystem: 'timers', exp: 'setImmediate'}, 22 | {subsystem: 'tls'}, 23 | {subsystem: 'url'}, 24 | {subsystem: 'util', exp: 'util.'}, 25 | {subsystem: 'vm'} 26 | ] 27 | 28 | module.exports = function () { 29 | return suggestions 30 | } 31 | -------------------------------------------------------------------------------- /lib/template.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | Upgrade utils report 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | {{#if diffs}} 16 |
17 |
18 | {{#if update}} 19 |

Your files were updated according to the changes described below, to complete the update follow these steps:

20 |
    21 |
  • Update your Nan dependency with npm install nan@latest --save
  • 22 |
  • Rebuild your module node-gyp rebuild 23 |
  • Check if there are errors and manually fix those
  • 24 |
25 |
26 | {{else}} 27 |

Your files were not touched this is a preview for all changes to apply in your files, to write these changes run the tool with the --update flag

28 | {{/if}} 29 |
30 | {{#each diffs}} 31 |
32 |

Lines changed in {{file}}

33 |
34 | {{#each changes}} 35 | {{#with added}} 36 |
+ {{../value}}
37 | {{/with}} 38 | {{#with removed}} 39 |
- {{../value}}
40 | {{/with}} 41 | {{/each}} 42 |
43 |
44 | {{/each}} 45 |
46 | {{/if}} 47 | 48 | {{#if suggestions}} 49 |
50 |

Suggested changes in your JavaScript files

51 | {{#each suggestions}} 52 |
53 |

{{doc}}

54 |

Please review changes in Node API for {{doc}} module used in these files:

55 |
    56 | {{#each files}} 57 |
  • {{this}}
  • 58 | {{/each}} 59 |
60 |
61 | {{{content}}} 62 |
63 |
64 |
65 | {{/each}} 66 |
67 | {{/if}} 68 | 69 | 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "upgrade-utils", 3 | "version": "1.0.5", 4 | "description": "A tool to help with the process of upgrading modules to the latest version of Node.js latest Node version (currently v4), replacing old NAN C++ bindings and adjusting for Node.js API changes", 5 | "main": "index.js", 6 | "scripts": { 7 | "lint": "standard .", 8 | "pretest": "npm run-script lint", 9 | "test": "istanbul cover ./node_modules/.bin/_mocha test", 10 | "posttest": "istanbul check-coverage --statements 85 --branches 70 --functions 100 --lines 90 && rm -rf coverage", 11 | "prepublish": "npm test && npm prune" 12 | }, 13 | "keywords": [ 14 | "Node", 15 | "v4", 16 | "NAN", 17 | "native", 18 | "update", 19 | "upgrade" 20 | ], 21 | "author": "NodeSource (https://nodesource.com)", 22 | "contributors": [ 23 | "Adrián Estrada (https://github.com/edsadr)", 24 | "Julián Duque (https://github.com/julianduque)" 25 | ], 26 | "bin": { 27 | "upgrade-utils": "./bin/upgrade-utils" 28 | }, 29 | "repository": { 30 | "type": "git", 31 | "url": "https://github.com/nodesource/upgrade-utils" 32 | }, 33 | "license": "MIT", 34 | "dependencies": { 35 | "async": "^1.4.2", 36 | "chalk": "^1.1.1", 37 | "diff": "^2.1.0", 38 | "graceful-fs": "^4.1.2", 39 | "handlebars": "^4.0.2", 40 | "marked": "^0.3.5", 41 | "minimist": "^1.2.0", 42 | "msee": "^0.1.1", 43 | "opener": "^1.4.1" 44 | }, 45 | "devDependencies": { 46 | "adm-zip": "^0.4.7", 47 | "chai": "^3.2.0", 48 | "istanbul": "^0.3.20", 49 | "mocha": "^2.3.2", 50 | "rimraf": "^2.4.3", 51 | "standard": "^5.1.1" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/resources/test-changed.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodesource/upgrade-utils/3f14c2a8b3a4b43238ceeb770fc4a766940c9448/test/resources/test-changed.zip -------------------------------------------------------------------------------- /test/resources/test-mod.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodesource/upgrade-utils/3f14c2a8b3a4b43238ceeb770fc4a766940c9448/test/resources/test-mod.zip -------------------------------------------------------------------------------- /test/test-bin.js: -------------------------------------------------------------------------------- 1 | /* 2 | global describe 3 | global it 4 | */ 5 | 6 | var assert = require('assert') 7 | var exec = require('child_process').exec 8 | var path = require('path') 9 | 10 | describe('upgrade-utils bin', function () { 11 | var cmd = 'node ' + path.join(__dirname, '../bin/upgrade-utils') + ' ' 12 | 13 | it('--help should run without errors', function (done) { 14 | exec(cmd + '--help', function (error, stdout, stderr) { 15 | assert(!error) 16 | done() 17 | }) 18 | }) 19 | 20 | it('--path should run without errors', function (done) { 21 | exec(cmd + '--path /tmp', function (error, stdout, stderr) { 22 | assert(!error) 23 | done() 24 | }) 25 | }) 26 | 27 | it('--extensions should run without errors', function (done) { 28 | exec(cmd + '--extensions .c,.cpp --path /tmp', function (error, stdout, stderr) { 29 | assert(!error) 30 | done() 31 | }) 32 | }) 33 | 34 | it('--quiet should run without errors', function (done) { 35 | exec(cmd + '--quiet --path /tmp', function (error, stdout, stderr) { 36 | assert(!error) 37 | done() 38 | }) 39 | }) 40 | 41 | it('--update should run without errors', function (done) { 42 | exec(cmd + '--update --path /tmp', function (error, stdout, stderr) { 43 | assert(!error) 44 | done() 45 | }) 46 | }) 47 | 48 | it('should return error on unknown command', function (done) { 49 | this.timeout(4000) 50 | 51 | exec(cmd + '-j', function (error, stdout, stderr) { 52 | assert(error) 53 | assert.equal(error.code, 1) 54 | done() 55 | }) 56 | }) 57 | }) 58 | -------------------------------------------------------------------------------- /test/test-module.js: -------------------------------------------------------------------------------- 1 | /* 2 | global describe 3 | global it 4 | global before 5 | global after 6 | */ 7 | 8 | var os = require('os') 9 | var path = require('path') 10 | var AdmZip = require('adm-zip') 11 | var rimraf = require('rimraf') 12 | var upgradeUtils = require('../index.js') 13 | var expect = require('chai').expect 14 | 15 | var tmp = path.join(os.tmpdir(), 'testmod') 16 | var tmp2 = path.join(os.tmpdir(), 'testchanged') 17 | 18 | function extractModule () { 19 | var zipFile = path.join(__dirname, 'resources', 'test-mod.zip') 20 | var zipFile2 = path.join(__dirname, 'resources', 'test-changed.zip') 21 | var zip = new AdmZip(zipFile) 22 | var zip2 = new AdmZip(zipFile2) 23 | zip.extractAllTo(tmp) 24 | zip2.extractAllTo(tmp2) 25 | } 26 | 27 | describe('Module testing', function () { 28 | before(function () { 29 | extractModule() 30 | }) 31 | 32 | after(function () { 33 | rimraf.sync(tmp) 34 | rimraf.sync(tmp2) 35 | }) 36 | 37 | it('should export a function', function (done) { 38 | expect(upgradeUtils).to.be.a('function') 39 | done() 40 | }) 41 | 42 | it('should check a module', function (done) { 43 | upgradeUtils(tmp, false, '.c,.cc,.cpp,.h,.hh,.hh,.js', true, done) 44 | }) 45 | 46 | it('should launch a log', function (done) { 47 | upgradeUtils(tmp, false, '.c,.cc,.cpp,.h,.hh,.js', false, done) 48 | }) 49 | 50 | it('should update the module', function (done) { 51 | upgradeUtils(tmp, true, '.c,.cc,.cpp,.h,.hh,.js', true, done) 52 | }) 53 | 54 | it('should not duplicate changes in the module', function (done) { 55 | upgradeUtils(tmp2, true, '.c,.cc,.cpp,.h,.hh', true, done) 56 | }) 57 | }) 58 | --------------------------------------------------------------------------------