當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs.appendFile函數代碼示例

本文整理匯總了TypeScript中fs.appendFile函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript appendFile函數的具體用法?TypeScript appendFile怎麽用?TypeScript appendFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了appendFile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: appendFile

    return new Promise<void>((resolve, reject) => {
      // Do filesystem stuff
      const lineStr = `${JSON.stringify(line)}\n`;
      appendFile(
        joinPath(
          '.',
          this.dir,
          `${this.currentId}.log`,
        ),
        lineStr,
        (err) => {
          if (err) {
            reject(err);
            return;
          }
          resolve();
        });

      // Add to cache
      if (!this.cache.has(this.currentId)) {
        this.cache.set(this.currentId, []);
      }
      const set = this.cache.get(this.currentId);
      set.push(line);
      if (set.length >= this.maxLogLength) {
        this.currentId += 1;
      }
    });
開發者ID:SecretOnline,項目名稱:bot,代碼行數:28,代碼來源:Logger.ts

示例2: function

app.get( '/tracker/1x1/:id', (req, resp, done) => {
  fs.appendFile('tracked.txt', req.params.id+',\n', function (err) {
    resp.writeHead(200, {'Content-Type': 'image/png' } );
    resp.end( trackerPNG );
    done();
  } );
} );
開發者ID:essential-cryptography,項目名稱:essentialcryptography.com,代碼行數:7,代碼來源:server.ts

示例3: resolve

    return new Promise<boolean>((resolve, reject) => {
      fs.appendFile(path, content, err => {

        if (err) return reject(err);
        resolve(true);
      });
    });
開發者ID:chen-framework,項目名稱:chen,代碼行數:7,代碼來源:filesystem.ts

示例4: Date

	proc.stderr.on('data', data => {
		var date = new Date().toLocaleString();
		fs.appendFile(`${tempFolder}/errors.log`, `${date}: ${data.toString()}`, (err) => {
			if (err) {
				throw new Error(`Could not write stderr to errors.log with the following error: ${err}`);
			};
		});
	});
開發者ID:vnvizitiu,項目名稱:vscode,代碼行數:8,代碼來源:main.ts

示例5: Promise

 return new Promise((resolve: Function, reject: Function): void =>
     fs.appendFile(histignoreFile, 'export HISTIGNORE="stymie *:$HISTIGNORE"\n', 'utf8', (err) => {
         if (err) {
             reject(err);
         } else {
             resolve('Updated $HISTIGNORE');
         }
     })
開發者ID:btoll,項目名稱:stymie-ts,代碼行數:8,代碼來源:install.ts

示例6: Date

	proc.stderr.on('data', data => {
		var date = new Date().toLocaleString();
		fs.appendFile(path.join(testDataPath, 'errors.log'), `${date}: ${data.toString()}`, (err) => {
			if (err) {
				throw new Error(`Could not write stderr to errors.log with the following error: ${err}`);
			};
		});
	});
開發者ID:kieferrm,項目名稱:vscode,代碼行數:8,代碼來源:main.ts

示例7: save

 static save(log: ILogger) {
     if (LogFactory.setting.storage == LogStorage.Console) {
         console.log(log);
         return;
     }
     fs.appendFile(LogFactory.logFile, `\n${JSON.stringify(log)}`, {encoding: 'utf8'}, err => {
         console.error(err);
     });
 }
開發者ID:VestaRayanAfzar,項目名稱:express-api-template,代碼行數:9,代碼來源:LogFactory.ts

示例8: bootstrapSbtProject

 ).then(choice => {
   if (choice === "Yes") {
     bootstrapSbtProject(buildSbtFileSource, dottyPluginSbtFileSource)
     return Promise.resolve()
   } else if (choice === "No") {
     fs.appendFile(disableDottyIDEFile, "", _ => {})
     return Promise.reject()
   }
 })
開發者ID:dotty-staging,項目名稱:dotty,代碼行數:9,代碼來源:extension.ts

示例9: function

GLOBAL.onError = function (err: any, res:express.Response) {
    console.log('onError error\n', err);
    //TODO Remove reason in production
    res.json({error:'error', reason:err});

    var str: string = "\r\n" + new Date().toLocaleString() + "\r\n";
    str += JSON.stringify(err);

    fs.appendFile(SERVER + '/error.log', str);
};
開發者ID:shumik-vladyslav,項目名稱:DigitalSignagePlayList,代碼行數:10,代碼來源:server.ts

示例10: updateResponseFile

function updateResponseFile(argsArray: string[], responseFile: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    fs.appendFile(responseFile, os.EOL + argsArray.join(os.EOL), function (err) {
        if (err) {
            defer.reject(err);
        }
        defer.resolve(responseFile);
    });
    return defer.promise;
}
開發者ID:ColinDabritz,項目名稱:vsts-tasks,代碼行數:10,代碼來源:vstest.ts

示例11: writeCSV

    function writeCSV(data: any): void {
        fs.appendFile("wolfgangsee-pegel.csv", `${data.date}, ${data.level}, ${data.temperature}\n`, (err) => {
            if (err) {
                console.error("Failed to write file", err);
                return;
            }

            console.log("CSV written successfully");
        });
    }
開發者ID:thred,項目名稱:wolfgangsee-pegel,代碼行數:10,代碼來源:wolfgangsee-pegel.ts

示例12: log

export function log(s: string) {
    let timed = new Date().toISOString() + "\t" + s;
    console.log(timed);
    fs.appendFile("./opencode.log", timed + "\n", function (err) {
        if (err) {
            return console.log("failed to write to log: " + err);
        }
    });
    logtrace.push(timed);
    if (logtrace.length > LOG_HISTORY) {
        logstart += (logtrace.length - LOG_HISTORY);
        logtrace.splice(0, logtrace.length - LOG_HISTORY);
    }
}
開發者ID:danelkhen,項目名稱:desktopbrowser,代碼行數:14,代碼來源:utils.ts

示例13: function

 this.serialPort.on('data', function (line) {
     try {
         fs.appendFile('gps.txt', line + '\r\n');
         var parsedData = nmea.parse(line);
         debug('Parsed: ' + JSON.stringify(parsedData));
         if (parsedData.hasOwnProperty('lat')) {
             self.status.latitude = parsedData.lat / 100;
             self.status.longitude = parsedData.lon / 100;
             self.status.altitude = parsedData.alt;
         }
     } catch (err) {
         debug('Could not parse: ' + line)
     }
 });
開發者ID:pierreca,項目名稱:msshuttle,代碼行數:14,代碼來源:gpsreader.ts

示例14: setInterval

 let id = setInterval(() => {
   let timestamp = moment().format('DD/MMM/YYYY:HH:mm:ss Z');
   let line = '127.0.0.1 user-identifier frank ['+timestamp+'] "GET /testing/apache_pb.gif HTTP/1.0" 200 2326' + '\n';
   if (n === 100){
     done();
     clearInterval(id);
   }
   if (Math.random() > 0.7) {
     appendFile('test.log', line, (err) => {
       if (err) throw err;
       n++;
     });
   }
 }, 10);
開發者ID:waltonseymour,項目名稱:http-monitor,代碼行數:14,代碼來源:alerts.ts

示例15: fetchAndConfigure

 ).then(choice => {
   if (choice == "Yes") {
     fs.readFile(languageServerDefaultConfigFile, (err, data) => {
       if (err) throw err
       else {
         const languageServerScalaVersion = data.toString().trim()
         fetchAndConfigure(coursierPath, sbtArtifact, languageServerScalaVersion, dottyPluginSbtFile).then(() => {
           runLanguageServer(coursierPath, languageServerArtifactFile)
         })
       }
     })
   } else {
     fs.appendFile(disableDottyIDEFile, "", _ => {})
   }
 })
開發者ID:olafurpg,項目名稱:dotty,代碼行數:15,代碼來源:extension.ts


注:本文中的fs.appendFile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。