| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 const fs = require('fs'); | 7 const fs = require('fs'); |
| 8 const path = require('path'); | 8 const path = require('path'); |
| 9 | 9 |
| 10 const utils = require('../utils'); | 10 const utils = require('../utils'); |
| 11 | 11 |
| 12 const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end'); | 12 const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end'); |
| 13 const OUT = path.resolve(__dirname, 'out', 'dependencies.dot'); | 13 const OUT_DIR_PATH = path.resolve(__dirname, 'out'); |
| 14 const OUT_FILE_PATH = path.resolve(OUT_DIR_PATH, 'dependencies.dot'); |
| 14 | 15 |
| 15 function main() { | 16 function main() { |
| 17 if (!utils.isDir(OUT_DIR_PATH)) |
| 18 fs.mkdirSync(OUT_DIR_PATH); |
| 16 const modules = new Set(); | 19 const modules = new Set(); |
| 17 const moduleToDependencyList = ['digraph dependencies {']; | 20 const moduleToDependencyList = ['digraph dependencies {']; |
| 18 moduleToDependencyList.push('fixedsize = true;') | 21 moduleToDependencyList.push('fixedsize = true;') |
| 19 fs.readdirSync(FRONTEND_PATH).forEach(function(file) { | 22 fs.readdirSync(FRONTEND_PATH).forEach(function(file) { |
| 20 const moduleJSONPath = path.join(FRONTEND_PATH, file, 'module.json'); | 23 const moduleJSONPath = path.join(FRONTEND_PATH, file, 'module.json'); |
| 21 if (fs.statSync(path.join(FRONTEND_PATH, file)).isDirectory() && | 24 if (fs.statSync(path.join(FRONTEND_PATH, file)).isDirectory() && |
| 22 utils.isFile(moduleJSONPath)) { | 25 utils.isFile(moduleJSONPath)) { |
| 23 const module = file; | 26 const module = file; |
| 24 if (module === 'audits2_worker') | 27 if (module === 'audits2_worker') |
| 25 return; | 28 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 | 45 |
| 43 if (moduleJSON.dependencies) { | 46 if (moduleJSON.dependencies) { |
| 44 for (let d of moduleJSON.dependencies) { | 47 for (let d of moduleJSON.dependencies) { |
| 45 moduleToDependencyList.push(` ${module} -> ${d}`); | 48 moduleToDependencyList.push(` ${module} -> ${d}`); |
| 46 } | 49 } |
| 47 } | 50 } |
| 48 } | 51 } |
| 49 }); | 52 }); |
| 50 moduleToDependencyList.push('}'); | 53 moduleToDependencyList.push('}'); |
| 51 const content = moduleToDependencyList.join('\n'); | 54 const content = moduleToDependencyList.join('\n'); |
| 52 fs.writeFileSync(OUT, content); | 55 fs.writeFileSync(OUT_FILE_PATH, content); |
| 53 } | 56 } |
| 54 | 57 |
| 55 if (require.main === module) | 58 if (require.main === module) |
| 56 main(); | 59 main(); |
| OLD | NEW |