"use strict";
// Commented out bc moved to codiac-ops-common
// import * as fs from "fs";
// import * as path from "path";
// import * as commentJson from 'comment-json'
// import { resolveHomeDir } from '@codiac.io/codiac-ops-common';
// import { CliPathWalker } from "./cli-path-walker"
// /** Statelss collection of commonly used json related functions. */
// export class JsonUtils {
//   /** Uses JSON.stringify() to write the given object to a file. Resolves tilde (~) path prefixes.
//    * @param subject The object to serialize.
//    * @param pathName Path and filename.  If relative (ie: not starting with / or ~), 
//    * it is interpreted as relative to the project root (eg: "src/app-config.json").
//    */
//   public static serializeJsonFile(subject: any, pathName: string): void {
//     let targetPathName = resolveHomeDir(pathName);
//     if (!path.isAbsolute(targetPathName)) { // Relative path (defaults relative to project root)
//       let root = CliPathWalker.getProjectRoot();
//       targetPathName = path.join(root, pathName);
//     }
//     if (!fs.existsSync(path.dirname(targetPathName))) {
//       fs.mkdirSync(path.dirname(targetPathName), { recursive: true });
//     }
//     fs.writeFileSync(targetPathName, JSON.stringify(subject, undefined, '  '))
//   }
//   /** Returns the instantiated object or array.  
//  * Returns undefined for both an empty or missing source file. 
//  * Uses JSON.parse and does not perform any explicit casting. Resolves tilde (~) path prefixes.
//  * @param pathName Fully qualified or relative path and filename of the json file.  
//  * If relative (ie: not starting with / or ~), it is interpreted as relative to the project root 
//  * (eg: "src/app-config.json").
//  * */
//   public static deserializeJsonFile<T>(pathName: string, allowComments: boolean = false): T | undefined {
//     try {
//       let targetPathName = resolveHomeDir(pathName);
//       if (!path.isAbsolute(targetPathName)) { // Relative path (defaults relative to project root)
//         let root = CliPathWalker.getProjectRoot();
//         targetPathName = path.join(root, pathName);
//       }
//       if (fs.existsSync(targetPathName)) {
//         let json = fs.readFileSync(targetPathName, { encoding: 'utf-8' });
//         if (allowComments) {
//           let obj = commentJson.parse(json);
//           return obj;
//         } else {
//           let obj = JSON.parse(json);
//           return obj;
//         }
//       } else {
//         return undefined;
//       }
//     } catch (err) {
//       // throw err;
//       console.log(err);  // Can we get this to use the main logger?  We need this class to load config files, which are needed to initialize the logger, so we prob cant.
//       return undefined;
//     }
//   }
// }
//# sourceMappingURL=json-utils.js.map