2020-09-26から1日間の記事一覧

child_processから起動させる

方法1 #!/usr/bin/env node const { spawn } = require('child_process') const subprocess = spawn('./node_modules/electron/cli.js', ['./index.js'], { 'stdio': ['inherit', 'inherit', 'inherit'] }) 方法2 PATHを通してコマンドを叩く const { spawn …

templatesとslots

概要 webコンポーネントのshadow DOMとしてポピュラーに使用されている templatesについて より簡単にマークアップを使い回す事ができる。 template要素とその中身はDOM内にはレンダーされないが、 JavaScriptを通して参照することが可能。 簡単なtemplate例 <template id="my-paragraph"></template>…

単位 em と rem

CSS

よく忘れるのでメモ。 どちらもfont-sizeを表す。 単位 説明 1 em 要素のfont-size 1 rem root要素のfont-size 要素の font-size が 10pxのとき 単位 サイズ[px] 1 em 10px 2 em 20px 3 em 30px 参照 ルート要素 (= html要素) developer.mozilla.org

command の 標準入出力 覚書

child_process.spawn(command [, args] [, options]) command を 新規のプロセスで実行し、subprocess を生成する。 (command は 子プロセスとなる) options.stdio command の標準入出力先を設定する。 pipe: デフォルト。commandの標準入出力は、subproces…

child_processを使ってVimを起動する

コード const { spawn } = require('child_process'); const subprocess = spawn( 'sh', [ '-c', 'vim' ], { stdio: ['inherit', 'inherit', 'inherit'] } ); // 2秒後に終了させる setTimeout(() => { subprocess.kill(); // Does not terminate the Node.j…