コード例 #1
0
 readFile(fileName) {
     const filePath = this.resolve(fileName);
     try {
         if (this._memoryHost.isFile(filePath)) {
             return core_1.virtualFs.fileBufferToString(this._memoryHost.read(filePath));
         }
         else {
             const content = this._syncHost.read(filePath);
             return core_1.virtualFs.fileBufferToString(content);
         }
     }
     catch (_a) {
         return undefined;
     }
 }
コード例 #2
0
 readJsonSync(path) {
     if (!this._syncHost) {
         this._syncHost = new core_1.virtualFs.SyncDelegateHost(this._host);
     }
     const data = this._syncHost.read(core_1.normalize('/' + path));
     return JSON.parse(core_1.virtualFs.fileBufferToString(data));
 }
コード例 #3
0
 Object.keys(files).forEach(fileName => {
     let content = files[fileName];
     if (typeof content == 'string') {
         content = core_1.virtualFs.stringToFileBuffer(content);
     }
     else if (content instanceof Buffer) {
         content = content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength);
     }
     this.scopedSync().write(core_1.normalize(fileName), content);
 });
コード例 #4
0
 return (fileName, data, _writeByteOrderMark, onError, _sourceFiles) => {
     const p = this.resolve(fileName);
     try {
         this._memoryHost.write(p, core_1.virtualFs.stringToFileBuffer(data));
     }
     catch (e) {
         if (onError) {
             onError(e.message);
         }
     }
 };
コード例 #5
0
ファイル: compiler_host.js プロジェクト: Leo-G/Flask-Scaffold
 readFile(fileName) {
     const p = this.resolve(fileName);
     const stats = this._files[p];
     if (!stats) {
         try {
             const result = core_1.virtualFs.fileBufferToString(this._syncHost.read(p));
             if (result !== undefined) {
                 if (this._cache) {
                     this._setFileContent(p, result);
                 }
             }
             return result;
         }
         catch (e) {
             return undefined;
         }
     }
     return stats.content;
 }
コード例 #6
0
ファイル: index.js プロジェクト: Leo-G/Flask-Scaffold
 })), this.getServerModuleBundlePath(options)).pipe(operators_1.switchMap(([[browserIndexOutputPath, indexContent], serverBundlePath]) => {
     const root = this.context.workspace.root;
     require_project_module_1.requireProjectModule(core_1.getSystemPath(root), 'zone.js/dist/zone-node');
     const renderModuleFactory = require_project_module_1.requireProjectModule(core_1.getSystemPath(root), '@angular/platform-server').renderModuleFactory;
     const AppServerModuleNgFactory = require(core_1.getSystemPath(serverBundlePath)).AppServerModuleNgFactory;
     const indexHtml = core_1.virtualFs.fileBufferToString(indexContent);
     const outputPath = core_1.join(root, options.outputIndexPath || browserIndexOutputPath);
     // Render to HTML and overwrite the client index file.
     return rxjs_1.from(renderModuleFactory(AppServerModuleNgFactory, {
         document: indexHtml,
         url: options.route,
     })
         .then((html) => {
         return this.context.host
             .write(outputPath, core_1.virtualFs.stringToFileBuffer(html))
             .toPromise();
     })
         .then(() => ({ success: true })));
 }));
コード例 #7
0
     .then((html) => {
     return this.context.host
         .write(outputIndexPath, core_1.virtualFs.stringToFileBuffer(html))
         .toPromise();
 })
コード例 #8
0
 return this._workspace.host.read(core_1.normalize(path)).pipe(operators_1.map(buffer => core_1.virtualFs.fileBufferToString(buffer)), operators_1.map(str => core_1.parseJson(str, core_1.JsonParseMode.Loose)));
コード例 #9
0
 const o = this._host.read(core_1.normalize('/' + path)).pipe(operators_1.map(content => JSON.parse(core_1.virtualFs.fileBufferToString(content))));
コード例 #10
0
 appendToFile(path, str) {
     const content = core_1.virtualFs.fileBufferToString(this.scopedSync().read(core_1.normalize(path)));
     this.scopedSync().write(core_1.normalize(path), core_1.virtualFs.stringToFileBuffer(content.concat(str)));
 }
コード例 #11
0
 replaceInFile(path, match, replacement) {
     const content = core_1.virtualFs.fileBufferToString(this.scopedSync().read(core_1.normalize(path)));
     this.scopedSync().write(core_1.normalize(path), core_1.virtualFs.stringToFileBuffer(content.replace(match, replacement)));
 }
コード例 #12
0
ファイル: config.js プロジェクト: Leo-G/Flask-Scaffold
 .subscribe(data => content = core_1.virtualFs.fileBufferToString(data));
コード例 #13
0
ファイル: compiler_host.js プロジェクト: babsacademy/compapp
 get bufferContent() {
     if (!this._bufferContent && this._content) {
         this._bufferContent = core_1.virtualFs.stringToFileBuffer(this._content);
     }
     return this._bufferContent || core_1.virtualFs.stringToFileBuffer('');
 }
コード例 #14
0
ファイル: compiler_host.js プロジェクト: babsacademy/compapp
 get content() {
     if (!this._content && this.bufferContent) {
         this._content = core_1.virtualFs.fileBufferToString(this.bufferContent);
     }
     return this._content || '';
 }