Skip to content

Commit

Permalink
Fix some Node 8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chancancode committed Aug 24, 2019
1 parent 942c301 commit 66dff2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ember-addon-main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const fs = require('fs');
const mkdirp = require('mkdirp');
const copyFileSync = require('fs-copy-file-sync');
const path = require('path');
const utils = require('./utils');
const addDependencyTracker = require("./addDependencyTracker");
Expand Down Expand Up @@ -82,10 +84,8 @@ export default setComponentTemplate(TEMPLATE, CLASS);`;

let outputPath = path.join(this.outputPath, possibleJSPath);

// TODO: check for compat with Node 8 (recursive may only be present in 10+)
// TODO: don't speculatively mkdirSync (likely do in a try/catch with ENOENT)
fs.mkdirSync(path.dirname(outputPath), { recursive: true });

mkdirp.sync(path.dirname(outputPath));
fs.writeFileSync(outputPath, jsContents, { encoding: 'utf8' });
});

Expand All @@ -98,10 +98,9 @@ export default setComponentTemplate(TEMPLATE, CLASS);`;
return;
}

// TODO: check for compat with Node 8 (recursive may only be present in 10+)
// TODO: don't speculatively mkdirSync (likely do in a try/catch with ENOENT)
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
fs.copyFileSync(inputPath, outputPath);
mkdirp.sync(path.dirname(outputPath));
copyFileSync(inputPath, outputPath);
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
"dependencies": {
"broccoli-persistent-filter": "^2.3.1",
"broccoli-plugin": "^2.0.0",
"fs-copy-file-sync": "^1.1.1",
"hash-for-dep": "^1.5.1",
"json-stable-stringify": "^1.0.1",
"mkdirp": "^0.5.1",
"strip-bom": "^3.0.0",
"walk-sync": "^1.1.3"
},
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4146,6 +4146,11 @@ from2@^2.1.1:
inherits "^2.0.1"
readable-stream "^2.0.0"

fs-copy-file-sync@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/fs-copy-file-sync/-/fs-copy-file-sync-1.1.1.tgz#11bf32c096c10d126e5f6b36d06eece776062918"
integrity sha512-2QY5eeqVv4m2PfyMiEuy9adxNP+ajf+8AR05cEi+OAzPcOj90hvFImeZhTmKLBgSd9EvG33jsD7ZRxsx9dThkQ==

fs-extra@^0.24.0:
version "0.24.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.24.0.tgz#d4e4342a96675cb7846633a6099249332b539952"
Expand Down

0 comments on commit 66dff2f

Please sign in to comment.