diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 6e3d58667..958549725 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -10,29 +10,29 @@ jobs: build: runs-on: ubuntu-latest container: - image: node:${{ matrix.node }}-alpine${{ matrix.alpine }} + image: node:${{ matrix.node }}-alpine strategy: fail-fast: false matrix: node: - 12 - 14 - - 15 - 16 + - 17 include: - node: 12 - alpine: "3.9" + python: python2 - node: 14 - alpine: "3.10" - - node: 15 - alpine: "3.10" + python: python3 - node: 16 - alpine: "3.11" + python: python3 + - node: 17 + python: python3 steps: - name: Install Alpine build tools - run: apk add --no-cache python make git gcc g++ + run: apk add --no-cache ${{ matrix.python }} make git gcc g++ - uses: actions/checkout@v2 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ccd70311a..67a6ecd14 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -35,6 +35,6 @@ jobs: run: npm run coverage - name: Coveralls GitHub Action - uses: coverallsapp/github-action@v1.1.2 + uses: coverallsapp/github-action@1.1.3 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint-js.yml b/.github/workflows/lint-js.yml index 21b60786b..320af3fee 100644 --- a/.github/workflows/lint-js.yml +++ b/.github/workflows/lint-js.yml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2.1.5 + - uses: actions/setup-node@v2.4.1 - name: Install packages run: npm install --unsafe-perm diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f82ae516f..e05b4f4f3 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -16,8 +16,8 @@ jobs: node: - 12 - 14 - - 15 - 16 + - 17 include: - node: 12 @@ -28,21 +28,21 @@ jobs: gcc: "gcc-6" gpp: "g++-6" os: ubuntu-18.04 - - node: 15 - gcc: "gcc-6" - gpp: "g++-6" - os: ubuntu-18.04 - node: 16 gcc: "gcc-8" gpp: "g++-8" os: ubuntu-18.04 + - node: 17 + gcc: "gcc-8" + gpp: "g++-8" + os: ubuntu-18.04 steps: - uses: actions/checkout@v2 - name: Setup Node.js environment - uses: actions/setup-node@v2.1.5 + uses: actions/setup-node@v2.4.1 with: node-version: ${{ matrix.node }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index cadeff24a..23959ab53 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -16,14 +16,14 @@ jobs: node: - 12 - 14 - - 15 - 16 + - 17 steps: - uses: actions/checkout@v2 - name: Setup Node.js environment - uses: actions/setup-node@v2.1.5 + uses: actions/setup-node@v2.4.1 with: node-version: ${{ matrix.node }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2d4a8db89..d3a7aa849 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,29 +16,34 @@ jobs: node: - 12 - 14 - - 15 - 16 + - 17 + + architecture: + - x64 + - x86 include: - node: 12 os: windows-2016 - node: 14 os: windows-2016 - - node: 15 - os: windows-2019 - node: 16 os: windows-2019 + - node: 17 + os: windows-2019 steps: - uses: actions/checkout@v2 - name: Setup Node.js environment - uses: actions/setup-node@v2.1.5 + uses: actions/setup-node@v2.4.1 with: node-version: ${{ matrix.node }} + architecture: ${{ matrix.architecture }} - name: Install packages - run: npm install --unsafe-perm + run: npm install env: SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true @@ -48,7 +53,7 @@ jobs: - uses: actions/upload-artifact@v2 if: github.repository_owner == 'sass' && github.event_name != 'pull_request' with: - name: ${{ matrix.node }} + name: ${{ matrix.node }}-${{ matrix.architecture }} path: | vendor/**/binding.node build/Release/binding.pdb diff --git a/README.md b/README.md index f19667a70..a1da0f363 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,13 @@ Projects that still use it should move onto 1. We will stop building binaries for unsupported releases, testing for breakages in dependency compatibility, but we will not block installations for those that want to support themselves. 1. New node release require minor internal changes along with support from CI providers (AppVeyor, GitHub Actions). We will open a single issue for interested parties to subscribe to, and close additional issues. -Below is a quick guide for minimum and maximum support supported version of node-sass: +Below is a quick guide for minimum and maximum supported versions of node-sass: NodeJS | Supported node-sass version | Node Module --------|-----------------------------|------------ +Node 17 | 7.0+ | 102 Node 16 | 6.0+ | 93 -Node 15 | 5.0+ | 88 +Node 15 | 5.0+, <7.0 | 88 Node 14 | 4.14+ | 83 Node 13 | 4.13+, <5.0 | 79 Node 12 | 4.12+ | 72 @@ -595,12 +596,13 @@ When compiling a directory `--source-map` can either be a boolean value or a dir node-sass supports different configuration parameters to change settings related to the sass binary such as binary name, binary path or alternative download path. Following parameters are supported by node-sass: -Variable name | .npmrc parameter | Process argument | Value ------------------|------------------|--------------------|------ -SASS_BINARY_NAME | sass_binary_name | --sass-binary-name | path -SASS_BINARY_SITE | sass_binary_site | --sass-binary-site | URL -SASS_BINARY_PATH | sass_binary_path | --sass-binary-path | path -SASS_BINARY_DIR | sass_binary_dir | --sass-binary-dir | path +Variable name | .npmrc parameter | Process argument | Value +-------------------------|--------------------------|----------------------------|------ +SASS_BINARY_NAME | sass_binary_name | --sass-binary-name | path +SASS_BINARY_SITE | sass_binary_site | --sass-binary-site | URL +SASS_BINARY_PATH | sass_binary_path | --sass-binary-path | path +SASS_BINARY_DIR | sass_binary_dir | --sass-binary-dir | path +SASS_REJECT_UNAUTHORIZED | sass_reject_unauthorized | --sass-reject-unauthorized | value These parameters can be used as environment variable: @@ -614,6 +616,8 @@ As a process argument: * E.g. `npm install node-sass --sass-binary-site=http://example.com/` +If you are using self-signed certificates for your binary then `SASS_REJECT_UNAUTHORIZED` will override (rejectUnauthorized)[https://nodejs.org/docs/latest/api/tls.html#tls_tls_createserver_options_secureconnectionlistener]. + ## Post-install Build Install runs only two Mocha tests to see if your machine can use the pre-built [LibSass] which will save some time during install. If any tests fail it will build from source. diff --git a/appveyor.yml b/appveyor.yml index 540a5f61e..c489a298c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,10 +39,10 @@ - nodejs_version: 14 GYP_MSVS_VERSION: 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - nodejs_version: 15 + - nodejs_version: 16 GYP_MSVS_VERSION: 2019 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - - nodejs_version: 16 + - nodejs_version: 17 GYP_MSVS_VERSION: 2019 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 @@ -77,61 +77,3 @@ secure: IZIifH990iABY3PQUtkRscTU/NOyYYwptGB6B1y2b618vpphV/2KD/4IWJzSAYAi on: appveyor_repo_tag: true # deploy on tag push only - -- - branches: - except: - - release - - /v\d\.\d\.\d/ - - skip_branch_with_pr: true - skip_tags: true - - os: Visual Studio 2017 - - configuration: testing - - platform: - - x86 - - version: "{build}" - - build: off - - clone_folder: c:\projects\node_modules\node-sass - - init: - - cmd: >- - subst s: c:\projects - - ps: set-location -path s:\node_modules\node-sass - - cache: - - '%userprofile%\.node-gyp' - - '%AppData%\npm-cache' - - environment: - SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true - matrix: - - nodejs_version: 12 - GYP_MSVS_VERSION: 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - nodejs_version: 14 - GYP_MSVS_VERSION: 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - nodejs_version: 15 - GYP_MSVS_VERSION: 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - - nodejs_version: 16 - GYP_MSVS_VERSION: 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - - install: - # https://www.appveyor.com/docs/lang/nodejs-iojs/#installing-any-version-of-nodejs-or-iojs - - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform - - node --version - - npm --version - - npm install - - test_script: - - ps: set-location -path c:\projects\node_modules\node-sass - - npm test diff --git a/bin/node-sass b/bin/node-sass index e948b66d1..7645ecbfd 100755 --- a/bin/node-sass +++ b/bin/node-sass @@ -18,91 +18,127 @@ var Emitter = require('events').EventEmitter, * Initialize CLI */ -var cli = meow({ - pkg: '../package.json', +var cli = meow(` + Usage: + node-sass [options] + cat | node-sass [options] > output.css + + Example: Compile foobar.scss to foobar.css + node-sass --output-style compressed foobar.scss > foobar.css + cat foobar.scss | node-sass --output-style compressed > foobar.css + + Example: Watch the sass directory for changes, compile with sourcemaps to the css directory + node-sass --watch --recursive --output css + --source-map true --source-map-contents sass + + Options + -w, --watch Watch a directory or file + -r, --recursive Recursively watch directories or files + -o, --output Output directory + -x, --omit-source-map-url Omit source map URL comment from output + -i, --indented-syntax Treat data from stdin as sass code (versus scss) + -q, --quiet Suppress log output except on error + -v, --version Prints version info + --output-style CSS output style (nested | expanded | compact | compressed) + --indent-type Indent type for output CSS (space | tab) + --indent-width Indent width; number of spaces or tabs (maximum value: 10) + --linefeed Linefeed style (cr | crlf | lf | lfcr) + --source-comments Include debug info in output + --source-map Emit source map (boolean, or path to output .map file) + --source-map-contents Embed include contents in map + --source-map-embed Embed sourceMappingUrl as data URI + --source-map-root Base path, will be emitted in source-map as is + --include-path Path to look for imported files + --follow Follow symlinked directories + --precision The amount of precision allowed in decimal numbers + --error-bell Output a bell character on errors + --importer Path to .js file containing custom importer + --functions Path to .js file containing custom functions + --help Print usage info +`, { version: sass.info, - help: [ - 'Usage:', - ' node-sass [options] ', - ' cat | node-sass [options] > output.css', - '', - 'Example: Compile foobar.scss to foobar.css', - ' node-sass --output-style compressed foobar.scss > foobar.css', - ' cat foobar.scss | node-sass --output-style compressed > foobar.css', - '', - 'Example: Watch the sass directory for changes, compile with sourcemaps to the css directory', - ' node-sass --watch --recursive --output css', - ' --source-map true --source-map-contents sass', - '', - 'Options', - ' -w, --watch Watch a directory or file', - ' -r, --recursive Recursively watch directories or files', - ' -o, --output Output directory', - ' -x, --omit-source-map-url Omit source map URL comment from output', - ' -i, --indented-syntax Treat data from stdin as sass code (versus scss)', - ' -q, --quiet Suppress log output except on error', - ' -v, --version Prints version info', - ' --output-style CSS output style (nested | expanded | compact | compressed)', - ' --indent-type Indent type for output CSS (space | tab)', - ' --indent-width Indent width; number of spaces or tabs (maximum value: 10)', - ' --linefeed Linefeed style (cr | crlf | lf | lfcr)', - ' --source-comments Include debug info in output', - ' --source-map Emit source map (boolean, or path to output .map file)', - ' --source-map-contents Embed include contents in map', - ' --source-map-embed Embed sourceMappingUrl as data URI', - ' --source-map-root Base path, will be emitted in source-map as is', - ' --include-path Path to look for imported files', - ' --follow Follow symlinked directories', - ' --precision The amount of precision allowed in decimal numbers', - ' --error-bell Output a bell character on errors', - ' --importer Path to .js file containing custom importer', - ' --functions Path to .js file containing custom functions', - ' --help Print usage info' - ].join('\n') -}, { - boolean: [ - 'error-bell', - 'follow', - 'indented-syntax', - 'omit-source-map-url', - 'quiet', - 'recursive', - 'source-map-embed', - 'source-map-contents', - 'source-comments', - 'watch' - ], - string: [ - 'functions', - 'importer', - 'include-path', - 'indent-type', - 'linefeed', - 'output', - 'output-style', - 'precision', - 'source-map-root' - ], - alias: { - c: 'source-comments', - i: 'indented-syntax', - q: 'quiet', - o: 'output', - r: 'recursive', - x: 'omit-source-map-url', - v: 'version', - w: 'watch' + flags: { + errorBell: { + type: 'boolean', + }, + functions: { + type: 'string', + }, + follow: { + type: 'boolean', + }, + importer: { + type: 'string', + }, + includePath: { + type: 'string', + default: [process.cwd()], + isMultiple: true, + }, + indentType: { + type: 'string', + default: 'space', + }, + indentWidth: { + type: 'number', + default: 2, + }, + indentedSyntax: { + type: 'boolean', + alias: 'i', + }, + linefeed: { + type: 'string', + default: 'lf', + }, + omitSourceMapUrl: { + type: 'boolean', + alias: 'x', + }, + output: { + type: 'string', + alias: 'o', + }, + outputStyle: { + type: 'string', + default: 'nested', + }, + precision: { + type: 'number', + default: 5, + }, + quiet: { + type: 'boolean', + default: false, + alias: 'q', + }, + recursive: { + type: 'boolean', + default: true, + alias: 'r', + }, + sourceMapContents: { + type: 'boolean', + }, + sourceMapEmbed: { + type: 'boolean', + }, + sourceMapRoot: { + type: 'string', + }, + sourceComments: { + type: 'boolean', + alias: 'c', + }, + version: { + type: 'boolean', + alias: 'v', + }, + watch: { + type: 'boolean', + alias: 'w', + }, }, - default: { - 'include-path': process.cwd(), - 'indent-type': 'space', - 'indent-width': 2, - linefeed: 'lf', - 'output-style': 'nested', - precision: 5, - quiet: false, - recursive: true - } }); /** @@ -282,10 +318,6 @@ function watch(options, emitter) { */ function run(options, emitter) { - if (!Array.isArray(options.includePath)) { - options.includePath = [options.includePath]; - } - if (options.directory) { if (!options.output) { emitter.emit('error', 'An output directory must be specified when compiling a directory'); diff --git a/lib/extensions.js b/lib/extensions.js index b18fd27ac..8f31450a3 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -4,11 +4,10 @@ var eol = require('os').EOL, fs = require('fs'), - pkg = require('../package.json'), - mkdir = require('mkdirp'), path = require('path'), - defaultBinaryDir = path.join(__dirname, '..', 'vendor'), - trueCasePathSync = require('true-case-path'); + trueCasePathSync = require('true-case-path'), + pkg = require('../package.json'), + defaultBinaryDir = path.join(__dirname, '..', 'vendor'); /** * Get the human readable name of the Platform that is running @@ -82,6 +81,7 @@ function getHumanNodeVersion(abi) { case 83: return 'Node.js 14.x'; case 88: return 'Node.js 15.x'; case 93: return 'Node.js 16.x'; + case 102: return 'Node.js 17.x'; default: return false; } } @@ -352,7 +352,7 @@ function getBinaryCachePath() { cachePath = path.join(cachePathCandidates[i], pkg.name, pkg.version); try { - mkdir.sync(cachePath); + fs.mkdirSync(cachePath, {recursive: true}); return cachePath; } catch (e) { // Directory is not writable, try another diff --git a/lib/render.js b/lib/render.js index 858e02e74..3539a9a16 100644 --- a/lib/render.js +++ b/lib/render.js @@ -4,7 +4,6 @@ var chalk = require('chalk'), fs = require('fs'), - mkdirp = require('mkdirp'), path = require('path'), sass = require('./'); @@ -66,7 +65,7 @@ module.exports = function(options, emitter) { emitter.emit('info', chalk.green('Rendering Complete, saving .css file...')); - mkdirp(path.dirname(destination), function(err) { + fs.mkdir(path.dirname(destination), {recursive: true}, function(err) { if (err) { return emitter.emit('error', chalk.red(err)); } @@ -85,7 +84,7 @@ module.exports = function(options, emitter) { if (sourceMap) { todo++; - mkdirp(path.dirname(sourceMap), function(err) { + fs.mkdir(path.dirname(sourceMap), {recursive: true}, function(err) { if (err) { return emitter.emit('error', chalk.red(err)); } diff --git a/package.json b/package.json index 265cbf476..f6297a1a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-sass", - "version": "6.0.0", + "version": "7.0.0", "libsass": "3.5.5", "description": "Wrapper around libsass", "license": "MIT", @@ -54,26 +54,25 @@ ], "dependencies": { "async-foreach": "^0.1.3", - "chalk": "^1.1.1", + "chalk": "^4.1.2", "cross-spawn": "^7.0.3", "gaze": "^1.0.0", "get-stdin": "^4.0.1", "glob": "^7.0.3", "lodash": "^4.17.15", - "meow": "^3.7.0", - "mkdirp": "^0.5.1", + "meow": "^9.0.0", "nan": "^2.13.2", "node-gyp": "^7.1.0", - "npmlog": "^4.0.0", + "npmlog": "^5.0.0", "request": "^2.88.0", "sass-graph": "2.2.5", "stdout-stream": "^1.4.0", "true-case-path": "^1.0.2" }, "devDependencies": { - "eslint": "^7.10.0", - "fs-extra": "^0.30.0", - "mocha": "^8.1.3", + "eslint": "^8.0.0", + "fs-extra": "^10.0.0", + "mocha": "^9.0.1", "nyc": "^15.1.0", "rimraf": "^3.0.2", "unique-temp-dir": "^1.0.0" diff --git a/scripts/build.js b/scripts/build.js index 5dcdd4d70..5c8a42b6e 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -3,7 +3,6 @@ */ var fs = require('fs'), - mkdir = require('mkdirp'), path = require('path'), spawn = require('cross-spawn'), sass = require('../lib/extensions'); @@ -24,7 +23,7 @@ function afterBuild(options) { : 'Release', 'binding.node'); - mkdir(path.dirname(install), function(err) { + fs.mkdir(path.dirname(install), {recursive: true}, function(err) { if (err && err.code !== 'EEXIST') { console.error(err.message); return; diff --git a/scripts/install.js b/scripts/install.js index 73740d32d..2cef34f7d 100644 --- a/scripts/install.js +++ b/scripts/install.js @@ -4,11 +4,10 @@ var fs = require('fs'), eol = require('os').EOL, - mkdir = require('mkdirp'), path = require('path'), - sass = require('../lib/extensions'), request = require('request'), log = require('npmlog'), + sass = require('../lib/extensions'), downloadOptions = require('./util/downloadoptions'); /** @@ -111,7 +110,7 @@ function checkAndDownloadBinary() { } try { - mkdir.sync(path.dirname(binaryPath)); + fs.mkdirSync(path.dirname(binaryPath), {recursive: true}); } catch (err) { console.error('Unable to save binary', path.dirname(binaryPath), ':', err); return; @@ -137,7 +136,7 @@ function checkAndDownloadBinary() { console.log('Caching binary to', cachedBinary); try { - mkdir.sync(path.dirname(cachedBinary)); + fs.mkdirSync(path.dirname(cachedBinary), {recursive: true}); fs.createReadStream(binaryPath) .pipe(fs.createWriteStream(cachedBinary)) .on('error', function (err) { diff --git a/scripts/util/downloadoptions.js b/scripts/util/downloadoptions.js index 23529716f..e9056b10e 100644 --- a/scripts/util/downloadoptions.js +++ b/scripts/util/downloadoptions.js @@ -1,5 +1,6 @@ var proxy = require('./proxy'), - userAgent = require('./useragent'); + userAgent = require('./useragent'), + rejectUnauthorized = require('./rejectUnauthorized'); /** * The options passed to request when downloading the bibary @@ -14,7 +15,7 @@ var proxy = require('./proxy'), */ module.exports = function() { var options = { - rejectUnauthorized: false, + rejectUnauthorized: rejectUnauthorized(), timeout: 60000, headers: { 'User-Agent': userAgent(), diff --git a/scripts/util/rejectUnauthorized.js b/scripts/util/rejectUnauthorized.js new file mode 100644 index 000000000..43d8373a6 --- /dev/null +++ b/scripts/util/rejectUnauthorized.js @@ -0,0 +1,46 @@ +var pkg = require('../../package.json'); + +/** + * Get the value of a CLI argument + * + * @param {String} name + * @param {Array} args + * @api private + */ +function getArgument(name, args) { + var flags = args || process.argv.slice(2), + index = flags.lastIndexOf(name); + + if (index === -1 || index + 1 >= flags.length) { + return null; + } + + return flags[index + 1]; +} + +/** + * Get the value of reject-unauthorized + * If environment variable SASS_REJECT_UNAUTHORIZED is non-zero, + * .npmrc variable sass_reject_unauthorized or + * process argument --sass-reject_unauthorized is provided, + * set rejectUnauthorized to true + * Else set to false by default + * + * @return {Boolean} The value of rejectUnauthorized + * @api private + */ +module.exports = function() { + var rejectUnauthorized = false; + + if (getArgument('--sass-reject-unauthorized')) { + rejectUnauthorized = getArgument('--sass-reject-unauthorized'); + } else if (process.env.SASS_REJECT_UNAUTHORIZED !== '0') { + rejectUnauthorized = true; + } else if (process.env.npm_config_sass_reject_unauthorized) { + rejectUnauthorized = process.env.npm_config_sass_reject_unauthorized; + } else if (pkg.nodeSassConfig && pkg.nodeSassConfig.rejectUnauthorized) { + rejectUnauthorized = pkg.nodeSassConfig.rejectUnauthorized; + } + + return rejectUnauthorized; +}; diff --git a/test/downloadoptions.js b/test/downloadoptions.js index de8963842..a6e2d9bae 100644 --- a/test/downloadoptions.js +++ b/test/downloadoptions.js @@ -8,7 +8,7 @@ describe('util', function() { describe('without a proxy', function() { it('should look as we expect', function() { var expected = { - rejectUnauthorized: false, + rejectUnauthorized: true, timeout: 60000, headers: { 'User-Agent': ua(), @@ -33,7 +33,7 @@ describe('util', function() { it('should look as we expect', function() { var expected = { - rejectUnauthorized: false, + rejectUnauthorized: true, proxy: proxy, timeout: 60000, headers: { @@ -57,6 +57,25 @@ describe('util', function() { delete process.env.HTTP_PROXY; }); + it('should look as we expect', function() { + var expected = { + rejectUnauthorized: true, + timeout: 60000, + headers: { + 'User-Agent': ua(), + }, + encoding: null, + }; + + assert.deepStrictEqual(opts(), expected); + }); + }); + + describe('with SASS_REJECT_UNAUTHORIZED set to false', function() { + beforeEach(function() { + process.env.SASS_REJECT_UNAUTHORIZED = '0'; + }); + it('should look as we expect', function() { var expected = { rejectUnauthorized: false, @@ -70,5 +89,47 @@ describe('util', function() { assert.deepStrictEqual(opts(), expected); }); }); + + describe('with SASS_REJECT_UNAUTHORIZED set to true', function() { + beforeEach(function() { + process.env.SASS_REJECT_UNAUTHORIZED = '1'; + }); + + it('should look as we expect', function() { + var expected = { + rejectUnauthorized: true, + timeout: 60000, + headers: { + 'User-Agent': ua(), + }, + encoding: null, + }; + + assert.deepStrictEqual(opts(), expected); + }); + }); + + describe('with npm_config_sass_reject_unauthorized set to true', function() { + beforeEach(function() { + process.env.npm_config_sass_reject_unauthorized = true; + }); + + it('should look as we expect', function() { + var expected = { + rejectUnauthorized: true, + timeout: 60000, + headers: { + 'User-Agent': ua(), + }, + encoding: null, + }; + + assert.deepStrictEqual(opts(), expected); + }); + + afterEach(function() { + process.env.npm_config_sass_reject_unauthorized = undefined; + }); + }); }); });