Skip to content

Instantly share code, notes, and snippets.

@kgtkr
Created February 1, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgtkr/c9e2a033275f7419260668d4f550c0d5 to your computer and use it in GitHub Desktop.
Save kgtkr/c9e2a033275f7419260668d4f550c0d5 to your computer and use it in GitHub Desktop.
お寿司復元
const fs = require("fs");
const mkdirp = require('mkdirp');
const path = require('path');
function isExistFile(file) {
try {
fs.statSync(file);
return true
} catch (err) {
if (err.code === 'ENOENT') return false
}
}
const map = JSON.parse(fs.readFileSync('main.js.map', 'utf-8'));
for (let i = 0; i < map.sources.length; i++) {
const file = "src/" + map.sources[i];
const dir = path.dirname(file);
const src = map.sourcesContent[i];
if (file.indexOf("../") === -1) {
console.log(file);
try {
fs.statSync(file);
} catch (_e) {
mkdirp.sync(dir);
}
fs.writeFileSync(file, src);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment